Thursday, 12 June 2014

A beginner's tutorial on Vim Editor-II


In command mode one can move the cursor using keyboard but not using the 'arrow keys'.In fact we can perform so many jobs in command mode.
Movement Basics:-
h ->moves cursor left
j ->moves cursor down one line
k ->move cursor up one line
l ->moves cursor to the right
0 ->moves cursor to the beginning of a line
$ ->moves cursor to the end of the line
w ->moves cursor forward one line
b ->moves cursor backward one line
G ->moves to the end of the file(i.e.,shift+g)
gg ->moves to the beginning of the file
Adding a digit will multiply the movement,i.e.,5w will move the cursor forward 5 words but of course use it effectively.
Saving and Qutitting:-
To save a piece of text or code one has to go to the last line mode,i.e, press : in command mode.You'll see a ':' in the last line of the screen
To write
w <filename> //filename is not necessary if it is given previously
To write and quit Vim
To quit without saving
To write over another file
w! <filename>
To quit if nothing has been changed
One can easily search a character through keyboard in command mode
/<text> -> searches forward from the cursor position
?<text> ->searches backward from the cursor position
eg. ?hello
searches the text 'hello' forward from the cursor position
If there are other 'hello's ahead you can find them pressing 'n' and if there are other 'hello's before you can find them pressing 'N'
Now apply these commands to your text written in vim to get the perfect effect.

No comments:

Post a Comment