A Look at the VI Editor - Cursor motion/movements (Page 3 of 4 )
To move your cursors in VI use the following commands (a long list!).
h | Move left |
j | Move down |
k | Move up |
l | Move right |
w | Move to next word |
W | Move to next blank delimited word |
b | Move to the beginning of the word |
B | Move to the beginning of blank delimited word |
^ | Moves to the first non-blank character in the current line |
+ | Moves to the first character in the next line |
- | Moves to the first non-blank character in the previous line |
e | Move to the end of the word |
E | Move to the end of blank delimited word |
( | Move a sentence back |
) | Move a sentence forward |
{ | Move a paragraph back |
} | Move a paragraph forward |
0 or | | Move to the beginning of the line |
$ | Move to the end of the line |
:n | Move to nth line of the file |
For jumping to the beginning of the document use [[, and use ]] to jump to the end of the document.
Deleting texts: To delete content use d and x. Use x for deleting character to the right of the cursor. Use d with the above operands (motion/movement operands) for deleting. To delete a word use dw (next word). Delete is basically cut, i.e. you can paste the deleted contents. The following are some other delete commands.
x | Delete character to the right of cursor |
nx | Deletes n characters starting with the current one; omitting n deletes current character only |
X | Deletes the character to the left of cursor |
nX | Deletes the previous n characters; omitting n deletes the previous character only |
D | Delete to the end of the line |
D$ | Deletes from the cursor to the end of the line |
dd or :d | Deletes the current line |
ndw | Deletes the next n words starting with the current word |
ndb | Deletes the previous n words starting with the current word |
ndd | Deletes n lines beginning with the current line |
:n,md | Deletes lines n through m |
Tips: You can edit multiple lines better if you know the line numbers. To show line numbers use the following command.
:set nu
For example, to go to line number 5 use :5
Next: Undo editing >>
More BrainDump Articles
More By Mamun Zaman