Vim tips Link to heading
Content Link to heading
Motions Link to heading
ciw
: Change the inner worddwi
: Delete current word and enter edit moded$
orD
: delete all after current position$
: go to the last char normal-modew
andb
: move a word forward or backwardsdaw
: delete from the current char til the first letter on next wordd9w
: delete 9 wordsdap
: delete around paragraphdd
: delete a line2dd
: delete two linesu
andctrl+o
: undo and redo editions4gt
: Go to Tab number 4
more of this:
0
: go to beginning$
: go the the endlineI
: Edit beginning lineA
: Edit end of the lineO
: Add blank line aboveo
: Add blank line belowJ
: Join bottom line to currentD
: Remove all to the end from current chardd
: remove linegg
: jump to first lineG
: jump to last line
Moving things around Link to heading
- Join (move) the line bellow at the end of the current:
gJ
- Join lines by removing tabs and newlines (supports visualmode):
J
- Split a long line in multiple sized lines:
%!fmt --width=75 --split-only
Edits Link to heading
shift+I
will go to the first letter in the line and enter edit modeshift+A
will go to the last letter in the line and enter edit mode
Files Link to heading
- gf - Edit existing file under cursor in same window
- C-W f - Edit existing file under cursor in split window
- C-W C-F - Edit existing file under cursor in split window
- C-W gf - Edit existing file under cursor in new tabpage
Buffers Link to heading
- C-W L - Moves a horizontal buffer to vertical
:sball
- Open all buffers horizontally splited
Search Link to heading
:g//#
: Incremental search and list matches with line numbers
Commands Link to heading
Deletions:
:.,$d
: From the current line to the end of the file.:.,1d
: From the current line to the beginning of the file.10,$d
: From the 10th line to the end of the file.
Deletions by search:
:g /word/d
: Delete lines that has word:g!/word/d
: The opposite:g/^$/d
: Delete blank lines
Copying and pasting
:364,757y
Copy range:364,757t2
Copy and paste two lines after current:364,757t.
Copy and paste in current line
Powerful plugins Link to heading
Git Link to heading
- Git blame
mkdx Link to heading
LEADER + I
: List headers in a bufferLEADER + i
: Update TOC
Copilot Link to heading
:Copilot enable
,:Copilot setup
Folding Link to heading
zf#j
creates a fold from the cursor down # lines.zf/string
creates a fold from the cursor to string .zj
moves the cursor to the next fold.zk
moves the cursor to the previous fold.zo
opens a fold at the cursor.zO
opens all folds at the cursor.zm
increases the foldlevel by one.zM
closes all open folds.zr
decreases the foldlevel by one.zR
decreases the foldlevel to zero – all folds will be open.zd
deletes the fold at the cursor.zE
deletes all folds.[z
move to start of open fold.]z
move to end of open fold.