Difference between revisions of "Vi IMproved"

From 6bit.ch wiki
Jump to navigation Jump to search
Line 26: Line 26:


=== multi-line inserting ===
=== multi-line inserting ===
Esc
Esc\\
Ctrl+V visual block mode
Ctrl+V visual block mode\\
Move Up/Down to select the columns
Move Up/Down to select the columns\\
Shift+i and type the text you want or Shift+x to delete
Shift+i and type the text you want or Shift+x to delete\\
Esc
Esc\\


== deleting ==
== deleting ==

Revision as of 22:33, 30 October 2024

vim

navigating

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 end of current line
ENTER : move to beginning of next line
Ctrl+f : go to next page
Ctrl+b : go to previous page
gg: go to beginning of file
Shft+G : go to end of file

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 the text you want or Shift+x to delete\\ Esc\\

deleting

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

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

/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)