Skip to content
Vim

Makros (Tastenaufzeichnungen)

Eine Tastensequenz aufzeichnen und abspielen, um wiederholte Edits zu automatisieren.

#macro#automation#register

Code

vim
" Record into register q
qa                  " start recording into q
0f,x                " example: go to line start, find comma, delete it
jq                  " move to next line, stop recording

" Replay
@q                  " replay q once on current line
5@q                 " replay q 5 times
@@                  " replay last used macro
:'a,'bnormal @q     " run q on every line from mark a to b
:%normal @q         " run q on every line in the file

" Editing a macro: paste the register, edit, yank back
:let @q = "0f,xj"   " assign macro as a string
"ip                  " insert register i contents for editing

" Recursive macros (end with @q to loop) — useful but advanced