USR_07

*usr_07.txt*    For IdeaVIM version 0.12.0.  Last change: 2006 Dec 29

                     IdeaVIM USER MANUAL - by Rick Maddy

                          Editing more than one file


No matter how many files you have, you can edit them without leaving IdeaVIM.
Define a list of files to work on and jump from one to the other.  Copy text
from one file and put it in another one.

|07.1|  Edit another file
|07.2|  A list of files
|07.3|  Jumping from file to file
|07.4|  Backup files
|07.5|  Copy text between files
|07.6|  Viewing a file
|07.7|  Changing the file name

     Next chapter: |usr_08.txt|  Splitting windows
 Previous chapter: |usr_06.txt|  Using syntax highlighting
Table of contents: |usr_toc.txt|


*07.1*  Edit another file

To start editing another file, use this command:

        :edit foo.txt

IdeaVIM will locate the file within the current IDEA project and open it in
another editor or select the editor if already open.


*07.2*  A list of files

To select the next editor in IDEA you use this coomand:

        :next

MOVING TO OTHER ARGUMENTS

To go back one file:

        :previous

This is just like the ":next" command, except that it moves in the other
direction.  Again, there is a shortcut command for when you want to write the
file first:

        :wprevious

To move to the very last file in the list:

        :last

And to move back to the first one again:

        :first

There is no ":wlast" or ":wfirst" command though!

You can use a count for ":next" and ":previous".  To skip two files forward:

        :2next




*07.3*  Jumping from file to file

To quickly jump between two files, press CTRL-^ (on English-US keyboards the ^
is above the 6 key).  Example:

        :args one.c two.c three.c

You are now in one.c.

        :next

Now you are in two.c.  Now use CTRL-^ to go back to one.c.  Another CTRL-^ and
you are back in two.c.  Another CTRL-^ and you are in one.c again.  If you now
do:

        :next

You are in three.c.  Notice that the CTRL-^ command does not change the idea
of where you are in the list of files.  Only commands like ":next" and
":previous" do that.

The file you were previously editing is called the "alternate" file.  When you
just started Vim CTRL-^ will not work, since there isn't a previous file.


FILE MARKS

In chapter 4 was explained how you can place a mark in a file with "mx" and
jump to that position with "`x".  That works within one file.  If you edit
another file and place marks there, these are specific for that file.  Thus
each file has its own set of marks, they are local to the file.
   So far we were using marks with a lowercase letter.  There are also marks
with an uppercase letter.  These are global, they can be used from any file.
For example suppose that we are editing the file "foo.txt".  Go to halfway the
file ("50%") and place the F mark there (F for foo):

        50%mF

Now edit the file "bar.txt" and place the B mark (B for bar) at its last line:

        GmB

Now you can use the "'F" command to jump back to halfway foo.txt.  Or edit yet
another file, type "'B" and you are at the end of bar.txt again.

The file marks are remembered until they are placed somewhere else.  Thus you
can place the mark, do hours of editing and still be able to jump back to that
mark.
   It's often useful to think of a simple connection between the mark letter
and where it is placed.  For example, use the H mark in a header file, M in
a Makefile and C in a C code file.

To see where a specific mark is, give an argument to the ":marks" command:

        :marks M

You can also give several arguments:

        :marks MCP

Don't forget that you can use CTRL-O and CTRL-I to jump to older and newer
positions without placing marks there.


*07.4*  Backup files

This information does not apply to IdeaVIM, it is handled by IDEA.


*07.5*  Copy text between files

This explains how to copy text from one file to another.  Let's start with a
simple example.  Edit the file that contains the text you want to copy.  Move
the cursor to the start of the text and press "v".  This starts Visual mode.
Now move the cursor to the end of the text and press "y".  This yanks (copies)
the selected text.
   To copy the above paragraph, you would do:

        :edit thisfile
        /This
        vjjjj$y

Now edit the file you want to put the text in.  Move the cursor to the
character where you want the text to appear after.  Use "p" to put the text
there.
        :edit otherfile
        /There
        p

Of course you can use many other commands to yank the text.  For example, to
select whole lines start Visual mode with "V".  Or use CTRL-V to select a
rectangular block.  Or use "Y" to yank a single line, "yaw" to yank-a-word,
etc.
   The "p" command puts the text after the cursor.  Use "P" to put the text
before the cursor.  Notice that Vim remembers if you yanked a whole line or a
block, and puts it back that way.


USING REGISTERS

When you want to copy several pieces of text from one file to another, having
to switch between the files and writing the target file takes a lot of time.
To avoid this, copy each piece of text to its own register.
   A register is a place where IdeaVIM stores text.  Here we will use the
registers named a to z (later you will find out there are others).  Let's copy
a sentence to the f register (f for First):

        "fyas

The "yas" command yanks a sentence like before.  It's the "f that tells IdeaVIM
the text should be place in the f register.  This must come just before the
yank command.
   Now yank three whole lines to the l register (l for line):

        "l3Y

The count could be before the "l just as well.  To yank a block of text to the
b (for block) register:

        CTRL-Vjjww"by

Notice that the register specification "b is just before the "y" command.
This is required.  If you would have put it before the "w" command, it would
not have worked.
   Now you have three pieces of text in the f, l and b registers.  Edit
another file, move around and place the text where you want it:

        "fp

Again, the register specification "f comes before the "p" command.
   You can put the registers in any order.  And the text stays in the register
until you yank something else into it.  Thus you can put it as many times as
you like.

When you delete text, you can also specify a register.  Use this to move
several pieces of text around.  For example, to delete-a-word and write it in
the w register:

        "wdaw

Again, the register specification comes before the delete command "d".


*07.6*  Viewing a file

This information does not apply to IdeaVIM.


*07.7*  Changing the file name

This information does not apply to IdeaVIM. Use Refactor|Rename in IDEA.


Next chapter: |usr_08.txt|  Splitting windows

Copyright: see |manual-copyright|