Vi Editing Multiple Files

Embed Size (px)

Citation preview

  • 7/30/2019 Vi Editing Multiple Files

    1/2

    Next:Merging filesUp:Guide to VI andPrevious:Global/Limited Search/Replace

    Editing Multiple Files

    vi can manipulate more than one file at the same time, therefore to edit three files in sequence, type:vi one two threeTo detect which file is currently edited use the exar (args) command::ar

    that types file list and flags current file at screen bottom as follows:one [two] three

    In this example, file two is in use.

    N.B. information is meaningful only when the current file is selected with one of the moving

    commands listed in the Moving command table. If the file is selected with the editingcommand, :ar flags as file in use the last file selected by a moving command, and not the file

    actually edited. Therefore to backspace over files, use :rew followed by the required number of nextfile movements.

    We can close the editing session by using:

    To move along files in the list:

    It is possible to preserve already edited files, as follows:

    :w write file with the following message at screen bottom:

    "vi_ex.doc" 670 lines, 27747 chars

    ZZ terminate current editing with the following message at screen bottom:

    2 more files to edit

    vi Multifile Moving Commands

    :n edit next file in the list

    : Nn advance n files in the list

    ~ toggle between the two last files

    :e# reopen previous file, same as above

    e file re-edit from disk

    :rew rewind file pointer to first file

    :rew! force rewind and immediatly reopen first file

    :ar list file names

    Page 1 of 2Editing Multiple Files

    05/11/2006http://www.bo.infn.it/alice/alice-doc/mll-doc/linux/vi-ex/node27.html

    http://www.bo.infn.it/alice/alicehttp://www.bo.infn.it/alice/alice
  • 7/30/2019 Vi Editing Multiple Files

    2/2

    When editing multiple files, current file is changed by one of the following options:

    l move forward to next file is the file list

    l toggle between the last two edited files

    l reopen name file

    l rewind file list and reopen first file in the list

    vi does not store multiple files in memory, therefore changes are lost unless a write command is

    issued before each of the moving commands. Write is accomplished by vi when the autowrite

    option is on.vi types the following messages when handling multiple file editing.

    Named buffers are preserved between files, thus we can copy (using p or P) named buffers contents

    into a later file in the series of files typed at vi start.

    N.B. Command zz must be used with care when using the w or the w! commands to write the current

    file to another file, as vi in this case does not write the current file.N.B. Note also that vi writes the output file in the same directory of the file specified with full pass

    at vi invocation. Ifvi is called from another directory with full path of input file, files written usingex commands from vi are stored in the working directory, not in the directory ofvi invocation

    input.

    Next:Merging filesUp:Guide to VI andPrevious:Global/Limited Search/ReplaceMarisa Luvisetto2000-12-20

    :set autowrite set autowrite option on

    :w write current file

    :q quit editing

    :q! force quitting, changes are lost

    vi Multiple Files Editing Messages

    No more files to edit :n as reached end of listCannot go beyond last file end of file list reached

    No write since last change (:edit! overrides) must save file before moving

    n.b. - :ar flags current file selected by move command, not file selected by :e

    Page 2 of 2Editing Multiple Files

    05/11/2006http://www.bo.infn.it/alice/alice-doc/mll-doc/linux/vi-ex/node27.html

    http://www.bo.infn.it/alice/alicehttp://www.bo.infn.it/alice/alice