Thursday, September 15, 2011

Basic vi Commands

Copy line               yy
Copy next n line        Nyy (N is number of lines to be copy)
Past line               p
Insert before cursor    i
Insert current line     I
Replace                 R
Delete                  [Delete]
Delete Line             dd
Undo                    u
                       
Page Up                 [Ctrl] + b
Page Down               [Ctrl] + f
To Begin of file        :0 or 1G
To End of file          :$ or G
Move To n line          :nG (n is number of line)
Move beginning of line  0
Move end of line        $


Search forward string   /string
Search backward string  ?string
to next match string    n
to prev match string    N


Save                    :w
Save and Exit           :x or :wq
Exit                    :q
Exit without save       :q!