0

I have a large block of text, and I want to insert comment delimiters // at the beginning of every line. I am using X11 forwarding to run GVim from a remote Linux box on my local windows machine. I can use the Ctrl+Q to enter the block selection mode as suggested in this post. When I try to press Shift+i to insert in the selected block, it deletes what I have selected and instead inserts the letter "I" at the top line of my selection and puts me in insert mode.

Any suggestions on how I can insert comment delimiters at the beginning of every line in a block? I would love to solve the problem with block insert, but a work-around would also be appreciated.

Community
  • 1
  • 1
GBleaney
  • 2,096
  • 2
  • 22
  • 40

3 Answers3

1

have you tried :s command?

  • select those lines

  • then :s#^#//#

Kent
  • 189,393
  • 32
  • 233
  • 301
0

The behavior of replacing the selection is a characteristic of select mode. You need to use visual mode for the column-insert via I.

How you got into select mode depends on your configuration. If <C-Q> gets you there, you likely have the cmd value in the 'selectmode' setting.

  This is a comma separated list of words, which specifies when to start
  Select mode instead of Visual mode, when a selection is started.
  Possible values:
     mouse        when using the mouse
     key          when using shifted special keys
     cmd          when using "v", "V" or CTRL-V

Also check the options listed under :help :behave. You may have turned on :behave mswin, and that causes all such unexpected effects.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
0

Your Vim is set to behave mswin. You can use :behave xterm to make it behave in the default manner, and then the other suggestions should work.

Ben
  • 1,113
  • 1
  • 7
  • 14