如何在Vim中选择整行作为动作?

时间:2017-12-18 04:05:58

标签: vim surround

我最近开始使用“环绕”插件。我意识到我不知道如何包围当前的线路。我的意思是,ysap<p>围绕一个段落,ysaw<p>围绕一个单词。显然dw删除了一个单词,das删除了一个句子。 dd会删除一行,但是第二个d不是我害怕的选择。那么ys??<p>一行?

2 个答案:

答案 0 :(得分:8)

重复syss),例如ccddyy

答案 1 :(得分:5)

What you are looking for is the <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div> <input type="checkbox" id="chk1" value="1" class="chk" />1 <input type="checkbox" id="chk2" value="2" class="chk" />2 <input type="checkbox" id="chk3" value="3" class="chk" />3 <input type="checkbox" id="chk4" value="4" class="chk" />4 <input type="button" id="btn" value="alert" /> </div> movement.

Ryan's answer is also right, _ is a easier to tip version of dd and a lot of commands have this optimization.

As it turns out, d_ has it too (thank you Ryan!) and cheats a bit.

As you can see with surround.vim it does actually not refer the current line, but the first non-blank character on the :h _ line downwards. This is the behaviour [count] -1 etc. uses. But isn't really what we want in your usecase, dd will actually give you this:

ys_

Instead of this:

"
line
"

So the "line" plugin "cheats" a bit, by implementing a surround.vim command which does not work like yss, dd or cc but works for the usecase it has.

So to answer the question as in the title: yy is the general solution.

If you are just looking for _ use Ryan's answer