Difference between revisions of "Vi IMproved"
| (11 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
= vim = | = vim = | ||
== navigating == | == navigating == | ||
| Line 18: | Line 9: | ||
b : move to start of previous word</br> | b : move to start of previous word</br> | ||
e : move to end of of next word</br> | e : move to end of of next word</br> | ||
</br> | |||
0 : move to beginning of current line</br> | 0 : move to beginning of current line</br> | ||
_ : move to beginning of current line (word)</br> | |||
$ : move to end of current line</br> | $ : move to end of current line</br> | ||
</br> | |||
ENTER : move to beginning of next line</br> | ENTER : move to beginning of next line</br> | ||
</br> | |||
{ : move up one paragraph</br> | |||
} : move down one paragraph</br> | |||
Ctrl+f : go to next page</br> | Ctrl+f : go to next page</br> | ||
Ctrl+b : go to previous page</br> | Ctrl+b : go to previous page</br> | ||
Ctrl+d : scroll down one page</br> | |||
Ctrl+u : scroll pup one page</br> | |||
</br> | |||
zz : center view</br> | |||
gg: go to beginning of file</br> | gg: go to beginning of file</br> | ||
G : go to end of file</br> | |||
</br> | |||
f ... : forward on to ...</br> | |||
t ... : forward up to ...</br> | |||
F ... : back on to ...</br> | |||
T ... : back up to ...</br> | |||
, . : scroll ...</br> | |||
</br> | |||
, ; : scroll ...</br> | |||
== inserting == | |||
i : insert text before the current position</br> | |||
I : insert text at the beginning of current line</br> | |||
a : append text after the current position</br> | |||
A : append text to the end of current line</br> | |||
o : open new line below current line</br> | |||
O : open new line above current line</br> | |||
=== multi-line inserting === | |||
Esc<br> | |||
Ctrl+v visual block mode<br> | |||
Move Up/Down to select the columns<br> | |||
Shift+i and type<br> | |||
Esc<br> | |||
== deleting == | == deleting == | ||
s : delete character and insert</br> | |||
S : delete line and insert</br> | |||
x : delete character at cursor</br> | x : delete character at cursor</br> | ||
X : delete character before cursor</br> | X : delete character before cursor</br> | ||
| Line 32: | Line 58: | ||
dd : delete current line</br> | dd : delete current line</br> | ||
D : delete from cursor to end of current line</br> | D : delete from cursor to end of current line</br> | ||
<nowiki>:</nowiki>6,12d : delete lines 6 through 12</br> | <nowiki>:</nowiki>6,12d : delete lines 6 through 12</br> | ||
Commands can be preceded by a number, indicating the number of steps</br> | Commands can be preceded by a number, indicating the number of steps</br> | ||
=== multi-line deleting === | |||
Esc<br> | |||
Ctrl+v visual block mode<br> | |||
Move Up/Down to select the columns<br> | |||
Shift+x and type<br> | |||
Esc<br> | |||
== undoing & repeating == | == undoing & repeating == | ||
| Line 43: | Line 77: | ||
== searching == | == searching == | ||
* : search forward for word under cursor</br> | |||
# : search backward for word under cursor</br> | |||
/string : search forward</br> | /string : search forward</br> | ||
?string : search backward</br> | ?string : search backward</br> | ||
| Line 62: | Line 98: | ||
<nowiki>:</nowiki>4,6m9 : move lines 4 through 6 after line 9</br> | <nowiki>:</nowiki>4,6m9 : move lines 4 through 6 after line 9</br> | ||
Commands can be preceded by a number, indicating the number of steps</br> | Commands can be preceded by a number, indicating the number of steps</br> | ||
</br> | |||
Shift-Insert : paste from clipboard (doesn't work on most systems) | |||
== changing == | == changing == | ||
Latest revision as of 21:30, 10 April 2025
vim
h : move back one character
j : move down one line
k : move up one line
l : move forward one character
w : move to start of next word
b : move to start of previous word
e : move to end of of next word
0 : move to beginning of current line
_ : move to beginning of current line (word)
$ : move to end of current line
ENTER : move to beginning of next line
{ : move up one paragraph
} : move down one paragraph
Ctrl+f : go to next page
Ctrl+b : go to previous page
Ctrl+d : scroll down one page
Ctrl+u : scroll pup one page
zz : center view
gg: go to beginning of file
G : go to end of file
f ... : forward on to ...
t ... : forward up to ...
F ... : back on to ...
T ... : back up to ...
, . : scroll ...
, ; : scroll ...
inserting
i : insert text before the current position
I : insert text at the beginning of current line
a : append text after the current position
A : append text to the end of current line
o : open new line below current line
O : open new line above current line
multi-line inserting
Esc
Ctrl+v visual block mode
Move Up/Down to select the columns
Shift+i and type
Esc
deleting
s : delete character and insert
S : delete line and insert
x : delete character at cursor
X : delete character before cursor
dw : delete word or part of word to the right of cursor
dd : delete current line
D : delete from cursor to end of current line
:6,12d : delete lines 6 through 12
Commands can be preceded by a number, indicating the number of steps
multi-line deleting
Esc
Ctrl+v visual block mode
Move Up/Down to select the columns
Shift+x and type
Esc
undoing & repeating
u : undo previous command
U : undo all changes on current line
:u : undo previous last line mode command
. (dot) : repeat last command
Commands can be preceded by a number, indicating the number of steps
searching
- : search forward for word under cursor
- : search backward for word under cursor
/string : search forward
?string : search backward
n : go to next occurrence
N : go to previous occurrence
replacing
:%s/old/new : replace first occurrence of old with new
:%s/old/new/g : replace all occurrences of old with new
Can be undone with :u
copy, move, paste
yl : yank current letter into buffer
yw : yank current word into buffer
yy : yank current line into buffer
p : paste yanked data below current line
P : paste yanked data above current line
:1,3co6 : copy lines 1 through 3, paste after line 6
:4,6m9 : move lines 4 through 6 after line 9
Commands can be preceded by a number, indicating the number of steps
Shift-Insert : paste from clipboard (doesn't work on most systems)
changing
cl : change letter at cursor
cw : change word at cursor until end of word
cc : change line
C : change text at cursor until end of line
r : replace character at cursor with character entered
R : overwrites/replaces text on the current line
J : join next line with current line
xp : switches position of character at cursor with the character to the right
~ : change letter case at cursor
Commands can be preceded by a number, indicating the number of steps
saving & quitting
:w : write without quit
:w file2 : write without quit to a new file
:w! : force write
:wq : write and quit
:wq! : force write and quit
:q : quit (no modifications)
:q! : force quit (no save)