在vim中缩进两个空格选择(视觉模式)?
假设我有这段代码:
var users = [
{ name: 'TJ', email: '[email protected]' },
{ name: 'Loki', email: '[email protected]' },
{ name: 'Jane', email: '[email protected]' }
];
我想选择变量内的三行(在可视模式下)并将其缩进两个空格:
var users = [
{ name: 'TJ', email: '[email protected]' },
{ name: 'Loki', email: '[email protected]' },
{ name: 'Jane', email: '[email protected]' }
];
如何在 vim 中实现这一点?
Say I have this code:
var users = [
{ name: 'TJ', email: '[email protected]' },
{ name: 'Loki', email: '[email protected]' },
{ name: 'Jane', email: '[email protected]' }
];
I want to select the three lines inside the variable (in visual mode) and indent it two spaces:
var users = [
{ name: 'TJ', email: '[email protected]' },
{ name: 'Loki', email: '[email protected]' },
{ name: 'Jane', email: '[email protected]' }
];
How can I accomplish that in vim?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您的
sw
为 2,您可以直观地选择三行 (V
) 并执行>
。您还可以选择一个空格和三行的列(ctrl-v),点击s
并将所述空格替换为三个空格,然后点击 esc,所有三行都将受益于这一改进。我确信还有更多方法。通常,您会执行>
并将sw
设置为您希望在代码中使用的任何缩进。Provided your
sw
is two, you can do visually select three lines (V
) and do a>
. You can also select column of one space and three lines (ctrl-v), hits
and replace the said space with three spaces, then hit esc and all three lines will benefit from this improvements. And there are more ways I'm sure. Normally, you'd do the>
and have yoursw
set to whatever indentation you want in your code.在视觉模式下选择线条后。输入“:”、“'<,'>”会自动添加,然后输入范数 I 和两个空格(空格键)。
after you select lines in visual mode. enter ":", the "'<,'>" will auto added, then enter norm I and two space(space key).
你的朋友是
:le
和:ri
:因此,只需直观地选择您的行,然后执行上述操作之一,例如:
或
(注意:
'<,'>
部分是由 VIM 自动创建的,它是您直观地选择的内容)Youre friend here are
:le
and:ri
:Thus just visually select your lines, and then execute one of the aboves like:
or
(Note: the
'<,'>
part is automatically created by VIM, it's the content that you have visually selected)用于在
{
和}
之间(或在()
、[]
之间)按应有的方式缩进块缩进,我使用=%
并将光标放在第一个{
(分别为(
,[
))。对于向右缩进 3 行,我使用
3>>
将光标置于第一行。For indenting a block between
{
and}
(or between()
,[]
) the way it should be indented, I use=%
with the cursor on the first{
(resp.(
,[
).For indenting 3 lines to the right, I use
3>>
with the cursor on the first line.