Does Vim have a certain syntax to combine commands on command mode? -
i noticed syntaxes when use vim
for example
[<motion>]<operator><motion> e.g. <gg><d><g> // delete top of file bottom of file <d><g> // delete current line bottom of file
and for
<operator><operator> e.g. <y><y> // inline copy <d><d> // inline delete <>><>> // inline right-indent
ok, these.
for syntax or way combine command know few patterns.
and me think there many ways combine commands on vim looks messy me
i think vim should have basis of command.
i know
does vim have syntax combine commands?
can give me further information this?
think of actions sentences , commands words in sentence: verbs, objects, prepositional phrases, modifiers grouped in sentence according grammar (like grammars) has corner cases makes lot of sense overall. hell, vim has transitive , intransitive verbs!
the basic rules quite simple:
{count}operator{motion} {count}operator{text-object}
if have clear idea of action want perform, using vim's language friction-less.
"cut block of lines , paste below function signature." become:
dip " cut paragraph ?func<cr> " move cursor first func above p " paste
instead of incredibly convoluted:
<home> " move cursor start of line <shift><down><down><down> " select block want move <c-x> " cut selection <up><up><up><up><up><up><up> " move target <end> " move cursor @ end of line <cr> " open new line <c-v> " (finally) paste lines
(edit)
the example above stands illustration of beauty of vim's editing model: there's little none "delta" between think , do. in more traditional editors, "delta" can huge because of unrelated steps necessary perform given task. because using vim speaking language fingers, have think in language efficient. gain more speed.
(endedit)
"paste 6 times." becomes awesome:
6p " paste 6 times
instead of:
<c-v><c-v><c-v><c-v><c-v><c-v>
other interesting rules:
- lowercase motions (
bwe
) work on keyword characters-delimitedwords
, - uppercase motions (
bwe
) work on whitespace-delimitedwords
, - some uppercase operators (
ftp
) work lowercase counterparts in opposite direction, - some uppercase operators (
ia
) work lowercase counterparts on extremities of line, - some other uppercase operators (
ycdvs
), doubled lowercase operators (yyddcc
) shortcuts commonoperator{motion}
sentences…
glts has written an awesome article on subject.
Comments
Post a Comment