vim 向内和向外缩进代码块
我正在使用 mvim 。我正在尝试映射键,以便可以直观地选择元素,然后可以向内或向外缩进代码。然而,在每次击键后进行外部工作时,底部的另一行会被选中。解决办法是什么。
" Ctrl-x - move the block of visually selected code one tab right and keep visual mode alive
" Ctrl-z moves the data in opposite direction
" Usage : shift v and select multiple lines. then Ctrl x multiple times and
" then Ctrl z multiple times
vmap <C-x> >gv
vmap <C-z> <gv
I am using mvim . I am trying to map keys so that I could visually select elements then I could indent the code inward or outward. However while doing outward work after every keystroke one more line at the bottom get selected. What is the fix.
" Ctrl-x - move the block of visually selected code one tab right and keep visual mode alive
" Ctrl-z moves the data in opposite direction
" Usage : shift v and select multiple lines. then Ctrl x multiple times and
" then Ctrl z multiple times
vmap <C-x> >gv
vmap <C-z> <gv
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当你已经可以做到这一点时,为什么还要去麻烦呢?
>>
- 增加所选块的缩进<<
- 减少所选块的缩进这将导致您失去焦点。如果您想继续缩进,只需输入 . 即可重复上一个操作。您还可以输入 gv 重新选择最后的选择。
另一种选择是在缩进之前选择并键入一个数字,这与重复
>>
或<<
次数与键入的数字相同。Why would you go to the trouble when you already can do this?
>>
- increase indent of selected block<<
- decrease indent of selected blockThis will cause you to lose the focus. If you want to continue indenting just type . to repeat the last action. You can also type gv to re-select your last selection.
Another option is to select and type a number before indenting, which is the same as repeating the
>>
or<<
as many times as the number you typed.