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,
ddis a easier to type version ofd_and a lot of commands have this optimization.As it turns out,
surround.vimhas 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] -1line downwards. This is the behaviourddetc. uses. But isn't really what we want in your usecase,ys_will actually give you this:Instead of this:
So the
surround.vimplugin "cheats" a bit, by implementing aysscommand which does not work likedd,ccoryybut 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.vimuse Ryan's answer