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
Ito insert in front of the block andAto insert after the block.Setting
'relativenumber'(:set rnu) could help to count lines.Start with CTRL-V to switch to blockwise select mode, then
8jto go down eight lines, thenI#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.vimactivated which remaps CTRL-V, use then CTRL-Q instead (or disable this plugin)