Skip to main content
Center for Biomolecular NMR Spectroscopy
HomeUser GuidelinesSpectrometersSchedulingFeesUNIX Software InformationEducation and USER BASELinksContact Us
The vi editor



The editor is in command mode unless --INSERT-- appears (at bottom)

To enter insert mode type i

To leave insert mode type <esc>

Arrow keys work in both modes.  Backspace only works within the last contiguous insert.  

In command mode h,j,k,l also work like the arrow keys.  Both forms
can take a number before to move multiple lines or spaces.  Note that 
a line is defined by hard returns, not lines on the screen.

Often a capital command means the same as lower case command, except before
cursor or backwards instead of forwards, indicated as x/X below.

Commands starting with : echo on command line.

Command summary:

Scrolling:
            (forward), (backwards)or U & D for 1/2 screen
            #G(go to line #), G (last line in file)
            H (top of screen), M (middle), L (bottom)
            ^E, ^Y (scoll screen one line down or up keeping cursor still)
            z (move current line to top), z. (to middle), z- (to bottom)
            ^L (refresh screen)

Cursor:
            ^(beg. of line), $ (end of line)
            0 (col. 1 = ^), #| (jump to particular column {char})
            #w(move # words ahead), #b(move # words back)
            #e (as w only positions on end of word)
            %(when over bracket, parentheses, etc. moves to paired element)
            { or } (beg. or end of paragraph)
            () (beg. or end of sentence)
            [[ (last case of { in 1st column)
            ]] (next case of { in 1st column)

Searching:
           /string (forward), ?string (backwards)
           f/F char (forward/backward search for char on line)
           t/T char (as f/F except positions cursor before char)
           ;(repeat last f or t), ,(reverse last f or t)

Replacing:
           :s/old/new (1st time this line), :s/old/new/g (all on line)
           :%s/old/new (1st time each line), :%s/old/new/g (all)
           r (overtype one char.) 
           R (overtype mode); use arrow keys and overtype
                -- REPLACE-- at bottom of screen; cancel with .
           #s (replaces # characters with what is typed next)
           #S (replaces # lines with what is typed next)
           c (replace until where movement specifies with next entry)

Deleting:
          #dd(number of lines), #dw(number of words)
          x/X(del char)
          d$ (to end of line), d) (to end of sentence)
          dt (up to next instance of )

Undo:
          u (last change)
          U (all changes on line, assuming you didn't move off it)

Pasting:
          p/P

Inserting:
          i (before cursor), a (after cursor)
          I (beg. of line), A (end of line)
          o(start new line), O(adds blank line, then new line)
          :r file (insert contents of file)

Copy:
          y (copy from cursor to where movement
          specifies into paste buffer; no cut)

Files:
          ZZ (save and exit), :w (save, no exit), :q! (quit, no save)
          :e file (edit new file)
          :n (go to next file on command line)
          :n! (next file and ignore saving the last one)

Bookmark:
          m char(mark position and name it char)
          ' char (return to position named char)
          '' return from last movement
          (only lower case characters)

Join:
          J (join two lines)

Repeat:
          . (repeat last command)

Case:
          ~ (change case, can be used recusively)

Buffers:
          The paste buffer is known as buffer #1
          "#p/P restores from deeper into the stack of 
          stored paste buffers ("3p recalls 3rd from last
          content of paste buffer)
          " before p,y,d accesses a named buffer

Margins:
          > or < movement (shift right or left til where movement says)
          >> or << (shift current line)

unix:
          ^Z (return to unix shell until fg to return to vi)
          ! (executes a unix command on the internal text, ie:)
          !}fmt (formats to end of paragraph to constant line length)
          !}sort (sort lines to end of paragraph)

Bar Break

Home  -  Getting Started  -  Spectrometers  -  Scheduling  -  Fees  -  UNIX Information  -  Technical Resources  -  Links  -  Contact
UTHSCSA  -  Center for Biomolecular Structure Analysis  -  Department of Biochemistry  -  Disclaimer  -  Copyright

Last updated on July 17, 2003