vim

vim

Vim, short for “Vi IMproved,” is a highly configurable and powerful text editor that is widely used by programmers and system administrators. It is known for its efficiency, versatility, and robustness, making it a popular choice for editing code and configuration files.

  1. Navigation
  2. Screen Navigation
  3. File Navigation
  4. Searching
  5. Modifying Text
  6. Editing Text

vim is a very nice and beautiful text editor. I just have to learn a bit of its intricacies.

Key bindings Descriptions
h j k l the arrow keys
b / w previous / word
ge / e previous / next end of word
0 / $ start / end of line
ff go forward to character f
Ff go backward to character f
gg first line
G last line
:{number} go to line {number}
{number}k go up {number} lines
{number}j go down {number} lines

Screen Navigation

Key bindings Descriptions
zz center this line
zt top this line
zb bottom this line
H M L move to top, middle, or bottom of the screen

File Navigation

Key bindings Descriptions
:tabedit [file] edit file in a new tab
:tabfind [file] open file if exists in new tab
:tabclose close current tab
:tabs lists all tabs
:tabfirst go to first tab
:tablast go to last tab
:tabn go to next tab
:tabp go to previous

Searching

Key bindings Descriptions
/{pattern} search
n next matching search pattern
N previous match
* next exact word under cursor
# previous exact word under cursor

Modifying Text

Key bindings Descriptions
a append
A append from end of line
i insert
o insert to next line
O insert to previous line
s delete char and insert
S delete line and insert
C delete until end of line and insert
r replace one character
R enter replace mode
u undo changes
Ctrl + R redo changes

Editing Text

Key bindings Descriptions
x delete character
dd cut
yy copy
p paste
P paste before
" * p paste from clipboard
" * y paste to clipboard
:%/foo/bar/g replace foo with bar in whole document
> indent right
< indent left
= autoindent
g~ / guu / gUU swap case / uppercase / lowercase

© 2024. knznsmn. All rights reserved.