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

前端 未结 10 679
悲哀的现实
悲哀的现实 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 14:02

    I like using the following:

    • put cursor on the first line you want to comment out
    • enter ma (no colon) to put a marker on that line
    • go to the last line of the block you want to comment out
    • enter :'a,.s/^/#/ and then enter

    That says, from the line containing marker "a", up to the current line, substitute a hash for the beginning of the line.

提交回复
热议问题