I recently started to use the "surround" plugin. I realized I don't know how to surround the current line. I mean, ysap<p>
surrounds a paragraph and ysaw<p>
surrounds a word. Apparently dw
deletes a word and das
deletes a sentence. dd
deletes a line, however, the second d
is not a selection I'm afraid. So ys??<p>
for a line?
How to select a whole line for as a motion in Vim?
4.1k Views Asked by huoenter At
2
What you are looking for is the
_
movement.Ryan's answer is also right,
dd
is a easier to type version ofd_
and a lot of commands have this optimization.As it turns out,
surround.vim
has it too (thank you Ryan!) and cheats a bit.As you can see with
:h _
it does actually not refer the current line, but the first non-blank character on the[count] -1
line downwards. This is the behaviourdd
etc. uses. But isn't really what we want in your usecase,ys_
will actually give you this:Instead of this:
So the
surround.vim
plugin "cheats" a bit, by implementing ayss
command which does not work likedd
,cc
oryy
but works for the usecase it has.So to answer the question as in the title:
_
is the general solution.If you are just looking for
surround.vim
use Ryan's answer