Vim 快速修改方法参数的方法
源代码最常见的操作之一是修改方法参数。 给定一个像这样的方法参数列表:
("argument1","argument2","argument3")
我想知道如何处理以下操作(我在这里使用 |
作为光标位置):
- 当光标位于引号内,并且您想删除引号内的内容时。 如:
"ar|gument1"
到"|"
- 与第一个相同,但删除引号。
- 把括号里的东西全部删掉。
("argument1","argument2","argument3")
到(|)
One of the most common operation with source code is to modify the method arguments.
Given a method argument list like this:
("argument1","argument2","argument3")
I wanna know how to deal with following operations(I use |
here as a cursor position):
- When cursor inside a quotes, and you wanna delete the contents inside the quotes.
like:"ar|gument1"
to"|"
- same as the first one, but delete the quotes.
- delete all the things in bracket.
("argument1","argument2","argument3")
to(|)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试以下命令:
di"
(助记符:删除 iniside"
)da"
(助记符:删除"
周围)di(
或dib
(助记:在()
对内删除)如果您想更改值(即删除并保持插入模式) ,使用
c
而不是d
有关更多信息和许多其他可能性,请检查
:help text-objects
。Try these commands:
di"
(mnemonic: delete iniside"
)da"
(mnemonic: delete around"
)di(
ordib
(mnemonic: delete inside()
pair)if you want to change the values (i.e. delete and remain in insert mode), use
c
instead ofd
.For more information, and a lot of other possibilities, check
:help text-objects
.bdw
-- 返回,删除单词,仅当光标不在第一个字符上时才有效。F"df"
-- 向后查找"
,删除直到向前下一个"
(含)。仅当光标不在左引号上时才有效。%c%()
-- 好吧,丑陋:)跳到括号开头,更改为匹配的括号,然后插入两个新的()
。bdw
-- back, delete word, only works if the cursor isn't on the first character.F"df"
-- find"
backwards, delete until next"
forwards (inclusive). Only works if the cursor isn't on the opening quotes.%c%()<esc>
-- okay, ugly :) bounce to start of parentheses, change up to the matching parenthesis, and insert two new()
.