old-www/HOWTO/C-editing-with-VIM-HOWTO/multi.html

232 lines
3.4 KiB
HTML

<HTML
><HEAD
><TITLE
> Multi-file editing
</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.57"><LINK
REL="HOME"
TITLE=" C editing with VIM HOWTO
"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE=" Formating automatically
"
HREF="auto-format.html"><LINK
REL="NEXT"
TITLE=" Quickfix
"
HREF="quickfix.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>C editing with VIM HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="auto-format.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="quickfix.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="MULTI"
>6. Multi-file editing</A
></H1
><P
>
One often needs to edit more than one file at a time. For
example one maybe editing a header file and a source file at
the same time. To edit more than one file at a time,
invoke VIM using the following command
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
> <TT
CLASS="PROMPT"
>$ </TT
><B
CLASS="COMMAND"
>vim file1 file2 ...</B
>
</PRE
></TD
></TR
></TABLE
><P
> Now you can edit the first file and move onto the next file
using the command
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
> <B
CLASS="COMMAND"
>:n</B
>
</PRE
></TD
></TR
></TABLE
><P
> You can jump back using the command
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
> <B
CLASS="COMMAND"
>:e#</B
>
</PRE
></TD
></TR
></TABLE
><P
> It may be useful while coding if you could see both the files
at the same time and switch between the two. In other words,
it would be useful if the screen was split and you could see
the header file at the top and the source file at the
bottom. VIM has such a command to split the screen. To invoke
i, simply say
<B
CLASS="COMMAND"
> :split
</B
>
</P
><P
> The same file will be displayed in both the windows. Whatever
command is invoked, will affect only the window in focus. So
one can edit another file in another window by using the
command
<B
CLASS="COMMAND"
> :e file2
</B
>
</P
><P
> After executing that command, you'll find that there are two
files visible. One window shows the first file and the other shows
the second file. To switch between the files one has to use the
keystroke <B
CLASS="KEYCAP"
>CTRL-W CTRL-W</B
>. To learn more about
split windows, just run help on it.
</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="auto-format.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="quickfix.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Formating automatically</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Quickfix</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>