Wednesday, April 16, 2008

Deleted Contents in Numbered[1-9] Buffers

If you have deleted some content (line(s) or word(s)) accidentally,
you can retrieve using Paste command (p or P).

For example,

In order to retrieve second latest deleted content:
Press Esc
Press "2p

Tuesday, April 8, 2008

Changing a Part of Word

All of us know cw (change word) command, to change a word.
It changes word from cursor to end of word. Suppose you want
to change a part of word.

for example: Mismanagement to Management

(i). Suppose your cursor is at M of Mismanagement, like
Mismanagement

(ii). Since you want to change only 4 characters "Mism" to "M",
Press c4l (Remembrall: Change 4 Left)
Then press M as replacement word. You will get
Management

Note

Friday, April 4, 2008

Search and Replace on VIM

1. Search and Replace All (Easiest)

Esc
:%s/old_pattern/new_pattern/g

2. Search and Replace selected

(a) Esc
(b) /old_pattern
(c) Go to desired by pressing n again and again
(d) Press cw (Change Word) and type
(e) Esc
(f) Press n to go to next old_pattern
(g) Press . if you want to do repeat last command used in step (c)

(h) Go to step (f), until all desired changes are made