d
is the delete operator.
Motion
w
> excluding its first character.
e
> Including the last character
pressing e
at first goes to the end of the first word then jumps to the end of the next words.
pressing b
will start jumping at the beginning of next word forward.
d number motion
You insert count before motion.
```2dd`` deletes two lines.
u
to undo last command, U
to fix a whole line and CTRL + r
for redo.
To put with p
place cursor above or before.
rx
replace the underline character with ‘x’.
ce
deletes character at cursor to the end of the line and puts in insert mode
c
is delete and insert.
CTRL + G
to show your location in the file and file status and information.
gg
to the top of the file, G
to the bottom of the file.
Type in line number than either press G
or gg
.
/
for forward search, ?
for reverse search. n
to find the next searched item forward. N
goes backward.
CTRL + o
puts where you had your cursor before, CTRL + i
goes forward.
%
to go the ending bracket if you are at the beginning bracket.
:s/new/old/g
for replace operation within the line. Without g
only changes first occurance. :%s
replaces throughout the file. You can also do it with ranges of line :beginning line number,ending line number
then s
.
Running a shell command from vim :!ls
so, :!
then command.
Writing files with name :w test
Using visual selection to write blocks of code to a seperate file. First select with v
then, :
to see the lines selected, then w test
.
Merging files :r test
retrieve the file test
and put in the cursor.
You can also input external command line output this way :r !ls
.
o
opens a line a below puts you on insert mode. O
opens a line above.
For multicharacter replace use R
. While in replace mode, as you write the underlying characters will be replaced.
For searching with ignore case :set ic
. To enable highlighting of found words :set hls is
Prepand ‘no’ to switch an option off :set noic
ctrl + w
to jump windows.
:help user-manual
Vimrc :help vimrc-intro
CTRL + d
shows the suggestions, tab
does autocomplete.