quick vim question

How do I take a visual selected block and move it over two spaces

example:

Code:
module WordProcessor

module Rendering
  DEFAULT_FONT = Font.new( 'default')
  DEFAULT_PAPER_SIZE = PaperSize.new
end

end

if I select the area beginning with module rendering and it's associated end to look like this:
Code:
module WordProcessor

  module Rendering
    DEFAULT_FONT = Font.new( 'default')
    DEFAULT_PAPER_SIZE = PaperSize.new
  end

end
 
  1. Get your cursor on the "m" in "module Rendering".
  2. <CTRL>-v (Note that this will select a VISUAL BLOCK as opposed to a VISUAL LINE)
  3. j
  4. j
  5. j
  6. I
  7. <SPACE>
  8. <SPACE>
  9. <ESCAPE>
  10. j

If you have trouble figuring out why that works, let me know. The spaces could be any characters you wanted to put in front of the visual block. E.g. substitute a "#" to comment out a block. And use "x" instead of the "I" to delete something, e.g. the comment characters you have just highlighted.

Gotta love vim. Where text editing is concerned, it is a man among boys. Here is a link to the vim theme song.
 
Without using blocks you can also use:

Code:
<ESC> <ESC>  # Make sure we're in command mode
I            # That's shift-I ; insert at the beginning of the line
<tab>        # Inserts a tab character
<ESC>        # Back to command mode
.            # The dot key (.) will repeat the last commands: Shift-I; <TAB> ; <ESC>
 
Back
Top