This topic was published by Saptarshi Nag and viewed 1545 times since "". The last page revision was "".
- Topics - 6
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.
[code]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[/code]
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 Quitting:-
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
[code]w <filename>[/code] //filename is not necessary if it is given previously
To write and quit Vim press [code]wq[/code]
To quit without saving press [code]q![/code]
To write over another file [code]w! <filename>[/code]
To quit if nothing has been changed press [code]q[/code]
One can easily search a character through keyboard in command mode
[code]/<text> -> searches forward from the cursor position[/code]
[code]?<text> ->searches backward from the cursor position[/code]
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.
Check out DCJTech's official Facebook page - http://dcjtech.info/members/saptarshi/