在 Vim 中注释/取消注释 ruby​​ 代码块的最优雅方式是什么? [英] What's the most elegant way of commenting / uncommenting blocks of ruby code in Vim?

查看:32
本文介绍了在 Vim 中注释/取消注释 ruby​​ 代码块的最优雅方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VIM中,当我需要注释掉一段Ruby代码时:

In VIM, at the moment when I need to comment out a section of Ruby code:

  • 我导航到要注释掉的行中的第一列
  • 我按 CTRL-v 进入可视块模式
  • 我向下导航直到我想结束操作的地方
  • 如果我想取消注释代码,我输入 r 或者如果我想注释掉它,输入 r#.
  • I navigate to the first column in the row I want to comment out
  • I press CTRL-v to enter visual block mode
  • I navigate down till the place I want to end the operation
  • I type r<space> if I want to uncomment the code or r# if I want to comment it out.

我觉得这个工作流程没问题,有什么方法可以改进这个流程吗?在 vim 中注释或取消注释 ruby​​ 代码部分还有其他技巧吗?

This workflow seems ok to me, are there any ways of improving this process? Are there any other tricks for commenting or uncommenting ruby code sections in vim?

推荐答案

我和你做的几乎一样.

评论:

  • 使用 CTRL-VI#(在开头插入 #)的视觉块选择
  • visual block select with CTRL-V then I# (insert # in the begining)

取消注释:

  • 使用 CTRL-VX(删除行上的第一个符号)进行视觉块选择
  • visual block select with CTRL-V then X (delete the first symbol on the line)

请注意大写IX.

这篇关于在 Vim 中注释/取消注释 ruby​​ 代码块的最优雅方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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