This topic was published by Saptarshi Nag and viewed 888 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.
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 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
w <filename>//filename is not necessary if it is given previously
To write and quit Vim press
To quit without saving press
To write over another file
To quit if nothing has been changed press
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
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/