Monday, May 29, 2006

Vim Movements

Moving Around
k (up),
h(left) l (right).
j (down)
(Ex 5k,j,3l )

Word Movement
w (Forward Word Movement Ex. f,5f )
b (Backword Word Movement Ex. b,2b)
e (Forward Word Movement at the end of word Ex. e,3e )
ge (Backword Word Movement at the end of word Ex. ge,3ge )

Moving to the Start or End of a Line
$(End Of Line Ex. $,2$)
^(Start Of Line Ex. ^,3^)

Searching Along a Single Line
f<Charcter> (Searching Charcter Forward Ex. fa, 2fv)
F<Charcter> (Searching Charcter Backword Ex. Fg,2Ft)
t<Charcter> (Search till Forward )
T<Charcter> (Search till Backword)

Moving to a Specific Line
<Line No.>G (Go to Line No.)
CTRL-G (Where I am in the File)
g CTRL-G (Count col, line, words and bytes)
CTRL-O Jump to previous location.
<TAB> Jump to next location (line 10).

Where are you in File
:set number
:set nonumber

Scrolling Up and Down
CTRL-U (scrolls up half a screen of text.)
CTRL-Y (scrolls up a line of text.)
CTRL-B (scrolls up a entire screen at a time.)
CTRL-D (scrolls down half a screen of text.)
CTRL-E (scrolls down one line.)
CTRL-F (scrolls down one screen of text.)
z<Enter> (screen line on the top)
88z<Enter> positions line 88 at the top.
zt (Leaves the cursor where it is.)
z- (scrolls line to the end of the screen)
zb (Leaves the cursor where it is)
z. (Center of the screen)
zz (Leaves the cursor where it is .)

:set scroll=10
:set scrolljump=5
:set scrolloff=3

Deleting
x delete character under the cursor (short for "dl")
X delete character before the cursor (short for "dh")
dw (Delete Word Ex. dw,3dw,d3w,3d2w,d$,d^,df> )
dd (Delete Line Ex. dd,3dd)
D (Delete up to end of line. )(short for "d$")
diw delete word under the cursor (excluding white space)
daw delete word under the cursor (including white space)
dG delete until the end of the file
dgg delete until the start of the file

Arthemetic
CTRL-A Incrmenting Number (123, 0177, 0x1f,-98)
CTRL-X Decrementing Number

:set nrformats=""

Changing Text
cw (Change Word Ex cw,c2w)
C stands for c$ (change to end of the line)
s stands for cl (change one character)
S stands for cc (change a whole line)

The . Command
It repeats the last delete or change command.

Joining Lines
J (Join Lines to One. Ex J,3J)
gJ (Join Lines without Spaces)

Replacing Charcter
r<Charcter> (Replace Charater Under Cursour. Ex. ru,5ra,3r<Enter> )
R<Charcter>

Changing Case
~ (Change Case of Character Ex. ~,12~,~fq)
U (Make the text Uppercase)
u (Make the text Lowercase)
g~motion (It does not depend on tildeop)
g~~ or g~g~ (Changes case of whole line)
gUmotion (All uppercase)
gUU (Changes to uppercase for whole line)
gUw (Changes to uppercase for word)
guw (Changes to lowercase for word)