如何在vi中的haml段落中注释掉? [英] How to comment out/in a paragraph of haml in vi?

查看:86
本文介绍了如何在vi中的haml段落中注释掉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始研究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: dCTRL-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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆