VIM Editor – Basic Commands

VIM Editor – Basic Commands

Vim editor is a versatile and extremely powerful tool for manipulating plain text, managing system configuration files, and programming. Vim has insertion and command mode, it begins with command mode, where the cursor movement and text deletion and pasting occur. Insertion mode begins upon entering an insertion or change command. [ESC] returns the editor to command mode. Most of the commands are executed instantly, except for “colon” commands which execute when you press the return key[Enter].

Here are few basic VIM commands

Cursor Movement Commands

h   Move left
j   Move down
k   Move up
l   Move right
w   Move to next word
W   Move to next blank delimited word
b   Move to the beginning of the word
B   Move to the beginning of blank delimted word
e   Move to the end of the word
E   Move to the end of Blank delimited word
(   Move a sentence back
)   Move a sentence forward
{   Move a paragraph back
}   Move a paragraph forward
0   Move to the begining of the line
$   Move to the end of the line
1G  Move to the first line of the file
G   Move to the last line of the file
nG  Move to nth line of the file
:n  Move to nth line of the file
fe  Move forward to e
Fe  Move back to e
H   Move to top of screen
M   Move to middle of screen
L   Move to botton of screen

Insertion commands

i Insert before cursor
I Insert before line
a Append after cursor
A Append after line
o Open a new line after current line
O Open a new line before current line
r Replace one character
R Replace many characters

Copy(Yank) Commands

yy  Copy the current line
:y  Copy the current line
yw  Copy one word, where the current cursor is placed
nyy Copies n lines starting with current line

Delete Commands

:x  Save and Exit
:q  Exit only when there are no changes, or else alert to save
ZZ  Save changes and Exit
:q! Force Exit without saving the changes

Paste Commands

p Paste after the cursor position or after the line
P Paste before the cursor position or before the line

Undo Commands

u Undo last change
U Undo all changes to line

Window Commands

[Crtl+w+arrow key] To Shift from one window to another
:vsp filename To open file in vertial window
:sp filename  To open file in horizontal window

Substitution Commands

:s/old/new/g to substitute 'new' for 'old' where g is globally
Categories: Uncategorized
Tags: ,