Vim - delete until (inclusive) character in multiple lines

▼魔方 西西 提交于 2020-12-29 09:06:24

问题


I have this code:

def foo(c: Char) = c match {
    case 'a': 'B'
}

My cursor is on the space after =. I want to delete everything until, including, the }. How can I do that?

Can I do the same where the cursor is anywhere on the first line? Anywhere in the block (and place the cursor after the =)?


回答1:


d/}/e

does the job.

d/} deletes until the } but adding the /e flag moves the cursor on the last char of the match, effectively deleting everything between the cursor and the }, inclusive.

Using visual selection works too, in a slightly more intuitive way:

v/}<CR>d



回答2:


Try with this: d%.

The d is for delete and the % moves between braces.




回答3:


This should work:

d}

This deletes one paragraph forward.




回答4:


You can achieve something like this with the EasyMotion plugin.



来源:https://stackoverflow.com/questions/19953741/vim-delete-until-inclusive-character-in-multiple-lines

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!