Reputation: 63616
I select a block of text using Ctrl-V, but when I then type Shift-A or Shift-I, my vim editor goes into insert mode on only the location where I began the visual block mode.
For example,
Here
is
text
I want
#Her
#is
#text
but I get:
#Here
is
text
Upvotes: 34
Views: 22941
Reputation: 35
I had the exact same issue and I'm not sure if it's because I'm on Mac OSX. I thought I needed to hit Esc twice. However, once you hit ESC it takes a second for it to place all the characters.
In the example below I ran the following commands:
Ctrl + v
6
j
Shift + i
#
space
Esc
Here's a screen recording of how it looks:
Upvotes: 0
Reputation: 1279
For me the problem was that I was using linewise visual mode (i.e. enter visual mode by pressing V
), rather than blockwise visual mode (i.e. enter visual mode by using Ctrl-v
). Also note that you have to exit visual mode by using <Esc>
(or equivalently by using Ctrl-[
on English keyboards) rather than by using Ctrl-c
.
Upvotes: 9
Reputation: 17
rpm -qa | grep vim
vim-enhanced-7.4.160-1.el7.x86_64
vim-common-7.4.160-1.el7.x86_64
vim-filesystem-7.4.160-1.el7.x86_64
1/just remove vi and use vim instead
or
2/alias vim='vi' in your bashrc
or
3/ln -s $(which vim) $(which vim|sed 's/vim/vi/g')
Upvotes: 0
Reputation: 195269
Ctrl-V-> select the block -> press I -> type #
then press ESC
more detail:
:h v_b_I
you can see:
Visual-block Insert *v_b_I*
With a blockwise selection, I{string}<ESC> will insert {string} at the start
of block on every line of the block, provided that the line extends into the block.
Upvotes: 26
Reputation: 16208
Make sure you exit visual block with ESC, not Ctrl C.
Also, Vim does not live update in visual block mode, you have to leave visual block mode to show the changes on other lines.
You will only see:
#Here
is
text
After you enter visual block and insert a #
, but once you leave visual block mode pressing ESC it should look like:
#Here
#is
#text
Upvotes: 36