如何在vi中的haml段落中注释掉? [英] How to comment out/in a paragraph of haml in vi?
问题描述
我刚刚开始研究vi,到目前为止,我只学习了基本的移动/编辑命令。在浏览本书时,有没有一种快速的方法可以用光标位置在同一列中用-#
注释一个段落(相应地缩进行)? / p>
假设我有一段代码:
%table
-除非是paginate(@clients).nil?
%tr
%th
= t('index.name')
%th
= t('index.address')
%th
= t('index.phone')
=渲染:partial => 客户,:collection => @clients
,我想注释掉-之间的行,除非
和 = render:partial
在一个列中带有-#
,然后可以再次对其进行注释。
在逐块选择模式下,您可以按 I
插入到块的前面, A
插入到块的后面。
设置相对编号
(:set rnu
)可以帮助计算行数。
从 CTRL-V 开始切换到逐块选择模式,然后 8j
下移八行,然后 I #
Esc 插入#
。
到删除它: d
CTRL-V 8j将逐块删除。
警告,如果您碰巧在Windows上使用了vanilla gvim.exe,您可能已激活 mswin.vim
,它会重新映射CTRL-V,然后使用CTRL-Q(或禁用此插件)
I just started diving into vi and so far learned only basic moving around/editing commands. While I am going through the book, is there a fast way to comment out a paragraph with -#
in the same column with the cursor position (indenting the lines accordingly)?
Let's say I have a piece of code:
%table
- unless paginate(@clients).nil?
%tr
%th
=t('index.name')
%th
=t('index.address')
%th
=t('index.phone')
=render :partial => 'client', :collection => @clients
and I want to comment out lines between - unless
and =render :partial
with -#
in one column and then be able to comment them in again. What command would that be?
In blockwise select mode, you can press I
to insert in front of the block and A
to insert after the block.
Setting 'relativenumber'
(:set rnu
) could help to count lines.
Start with CTRL-V to switch to blockwise select mode, then 8j
to go down eight lines, then I#
Esc to insert the #
.
To remove it: d
CTRL-V8j will delete blockwise.
Warning, if you happen to use vanilla gvim.exe on Windows, you probably have mswin.vim
activated which remaps CTRL-V, use then CTRL-Q instead (or disable this plugin)
这篇关于如何在vi中的haml段落中注释掉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!