What's the most elegant way of commenting / uncommenting blocks of ruby code in Vim?

前端 未结 10 684
悲哀的现实
悲哀的现实 2021-01-30 13:23

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

  • I navigate to the first column in the row I want to comment out
  • I press CTRL-v t
10条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 13:52

    Try T-comment with Ruby block.

    I have T-comment mapped to //.

    " Easy commenting
    nnoremap // :TComment
    vnoremap // :TComment
    

    This allows, from anywhere in a Ruby block, to comment it out with:

    var  (visual around Ruby)
    //   (toggle comments)
    

    Note that Ruby blocks has a couple of plugin dependencies that need installing, see my Vimfiles for an example.

提交回复
热议问题