vi help

"vi" is a standard text editor. It has an esoteric set of commands, that at first may not be intuitive, but is really effiencent. Basically, there are three operational modes: insertion, free-floating, and command-line. Those of you who would like to try an editor with a slightly less UNIX bias than vi, we recommend EMACS.

These tips are copied from the Sun Microsystems "vi" manual page.
     In the descriptions, CR stands for carriage return  and  ESC
     stands for the escape key.

  Sample commands
     left down up rght arrow keys move the cursor
     h j k l           same as arrow keys
     itextESC          insert text
     cwnewESC          change word to new
     easESC            pluralize word (end of word; append s;
                       escape from input state)
     x                 delete a character
     dw                delete a word
     dd                delete a line
     3dd               delete 3 lines
     u                 undo previous change
     ZZ                exit vi, saving changes
     :q!CR             quit, discarding changes
     /textCR           search for text
     ^U ^D             scroll up or down
     :cmdCR            any ex or ed command

  Counts before vi commands
     Numbers may be typed as a prefix to some commands.  They are
     interpreted in one of these ways.
     line/column number   z  G  |
     scroll amount        ^D  ^U
     repeat effect        most of the rest

  Interrupting, canceling
      ESC       end insert or incomplete cmd
      DEL       (delete or rubout) interrupts

  File manipulation
      ZZ              if file modified, write and exit; otherwise, exit
      :wCR            write back changes
      :w!CR           forced write, if permission originally not valid
      :qCR            quit
      :q!CR           quit, discard changes
      :e nameCR       edit file name
      :e!CR           reedit, discard changes
      :e + nameCR     edit, starting at end
      :e +nCR         edit starting at line n
      :e #CR          edit alternate file
      :e! #CR         edit alternate file, discard changes
      :w nameCR       write file name
      :w! nameCR      overwrite file name
      :shCR           run shell, then return
      :!cmdCR         run cmd, then return
      :nCR            edit next file in arglist
      :n argsCR       specify new arglist
      ^G              show current file and line
      :ta tagCR       position cursor to tag

     In general, any ex or ed command (such as substitute or glo-
     bal)  may  be  typed,  preceded by a colon and followed by a
     carriage return.

  Positioning within file
      ^F          forward screen
      ^B          backward screen
      ^D          scroll down half screen
      ^U          scroll up half screen
      nG          go to the beginning of the specified line (end default),
                  where n is a line number
      /pat        next line matching pat
      ?pat        previous line matching pat
      n           repeat last / or ? command
      N           reverse last / or ? command
      /pat/+n     nth line after pat
      ?pat?-n     nth line before pat
      ]]          next section/function
      [[          previous section/function
      (           beginning of sentence
      )           end of sentence
      {           beginning of paragraph
      }           end of paragraph
      %           find matching ( ) { or }

  Adjusting the screen
      ^L            clear and redraw window
      ^R            clear and redraw window if ^L is -> key
      zCR           redraw screen with current line at top of window
      z-CR          redraw screen with current line at bottom of window
      z.CR          redraw screen with current line at center of window
      /pat/z-CR     move pat line to bottom of window
      zn.CR         use n-line window
      ^E            scroll window down 1 line
      ^Y            scroll window up 1 line

  Marking and returning
      ``      move cursor to previous context
      ''      move cursor to first non-white space in line
      mx      mark current position with the ASCII lower-case letter x
      `x      move cursor to mark x
      'x      move cursor to first non-white space in line marked by x

  Line positioning
      H          top line on screen
      L          last line on screen
      M          middle line on screen
      +          next line, at first non-white
      -          previous line, at first non-white
      CR         return, same as +
      |v or j     next line, same column
      |^ or k     previous line, same column

  Character positioning
      ^           first non white-space character
      0           beginning of line
      $           end of line
      h or ->     forward
      l or <-     backward
      ^H          same as <- (backspace)
      space       same as -> (space bar)
      fx          find next x
      Fx          find previous x
      tx          move to character prior to next x
      Tx          move to character following previous x
      ;           repeat last f, F, t, or T
      ,           repeat inverse of last f, F, t, or T
      n|          move to column n
      %           find matching ( { ) or }

  Words, sentences, paragraphs
      w       forward a word
      b       back a word
      e       end of word
      )       to next sentence
      }       to next paragraph
      (       back a sentence
      {       back a paragraph
      W       forward a blank-delimited word
      B       back a blank-delimited word
      E       end of a blank-delimited word

Corrections during insert
      ^H         erase last character (backspace)
      ^W         erase last word
      erase      your erase character, same as ^H (backspace)
      kill       your kill character, erase this line of input
      \          quotes your erase and kill characters
      ESC        ends insertion, back to command mode
      CTRL-C     interrupt, suspends insert mode
      ^D         backtab one character; reset left margin of autoindent
      ^^D        caret (^) followed by control-d (^D);
                 backtab to beginning of line;
                 do not reset left margin of autoindent
      0^D        backtab to beginning of line; reset left margin of autoindent
      ^V         quote non-printable character

  Insert and replace
      a            append after cursor
      A            append at end of line
      i            insert before cursor
      I            insert before first non-blank
      o            open line below
      O            open above
      rx           replace single char with x
      RtextESC     replace characters

     Operators are followed by a cursor motion,  and  affect  all
     text  that would have been moved over.  For example, since w
     moves over a word, dw deletes the word that would  be  moved
     over.   Double the operator, for example, dd to affect whole
      d       delete
      c       change
      y       yank lines to buffer
      <       left shift
      >       right shift
      !       filter through command

  Miscellaneous Operations
      C       change rest of line (c$)
      D       delete rest of line (d$)
      s       substitute chars (cl)
      S       substitute lines (cc)
      J       join lines
      x       delete characters (dl)
      X       delete characters before cursor (dh)
      Y       yank lines (yy)

Yank and Put
     Put inserts the text most recently deleted or  yanked;  how-
     ever,  if  a  buffer  is  named  (using the ASCII lower-case
     letters a - z), the text in that buffer is put instead.
      3yy     yank 3 lines
      3yl     yank 3 characters
      p       put back text after cursor
      P       put back text before cursor
      "xp     put from buffer x
      "xy     yank to buffer x
      "xd     delete into buffer x

  Undo, Redo, Retrieve
      u       undo last change
      U       restore current line
      .       repeat last change
      "dp     retrieve d'th last delete

ex Command Names and Abbreviations abbrev ab map set se append a mark ma shell sh args ar move m source so change c next n substitute s copy co number nu unabbrev unab delete d preserve pre undo u edit e print p unmap unm file f put pu version ve global g quit q visual vi insert i read r write w join j recover rec xit x list l rewind rew yank ya ex Commands forced encryption C heuristic encryption X resubst & print next CR rshift > lshift < scroll ^D window z shell escape ! ex Command Addresses n line n /pat next with pat . current ?pat previous with pat $ last x-n n before x + next x,y x through y - previous 'x marked with x +n n forward '' previous context % 1,$ Initializing options EXINIT place set's here in environment variable $HOME/.exrc editor initialization file ./.exrc editor initialization file set x enable option x set nox disable option x set x=val give value val to option x set show changed options set all show all options set x? show value of option x Most useful options and their abbreviations autoindent ai supply indent autowrite aw write before changing files directory pathname of directory for temporary work files exrc ex allow vi/ex to read the .exrc in the current directory. This option is set in the EXINIT shell variable or in the .exrc file in the $HOME directory. ignorecase ic ignore case of letters in scanning list print ^I for tab, $ at end magic treat . [ * special in patterns modelines first five lines and last five lines executed as vi/ex commands if they are of the form ex:command: or vi:command: number nu number lines paragraphs para macro names that start paragraphs redraw simulate smart terminal report informs you if the number of lines modified by the last command is greater than the value of the report variable scroll command mode lines sections sect macro names that start sections shiftwidth sw for < >, and input ^D showmatch sm to ) and } as typed showmode smd show insert mode in vi slowopen slow stop updates during insert term specifies to vi the type of terminal being used (the default is the value of the environment variable TERM) window visual mode lines wrapmargin wm automatic line splitting wrapscan ws search around end (or beginning) of buffer

=cec= Tuesday, March 21, 1995 @ 09:50AM.