Reputation: 41143
My ec2 server came with redhat vim:
[ec2-user@****** ~]$ vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jul 7 2012 08:03:48)
Included patches: 1-411
Modified by <[email protected]>
Compiled by <[email protected]>
I've read the wikia doc and many posts such as:
All of the guide told me to do Ctrl+V
, select the area, then Shift+i
, type the character to be inserted, and ESC
. This doesn't work for me.
I can however do :s/^/\
and this will insert a space in front of each line, but how can I insert it in somewhere in the middle?
For example, I want to insert several spaces to turn
hello world
a cute cat
milky way
into
hello world
a cut e cat
milky way
In one visual block operation
Upvotes: 2
Views: 1313
Reputation: 20516
Solution to your updated question:
2j
to select that columnI
Here's a small demo:
Upvotes: 4
Reputation: 454
If you are looking for a regex style answer try (matches what Visual-Block mode would have done):
:%s;\v^(.{5})(.*);\1 \2;g
To match your expected output:
:%s;\v^(.{5})\s*(.*);\1 \2;g
If you need this done only on lines 1 through 3:
:1,3s;\v^(.{5})(.*);\1 \2;g
Upvotes: 1
Reputation: 7688
Visual-block Insert is what you are trying to do with Shift+i
. It is a blockwise operator
:h blockwise-operators
Blockwise operators are not available when vim is compiled without the +visualextra feature.
To check if you have this feature
:version
If you do not, then you may have to use the methods suggested in the other answers or, get another version of vim.
Upvotes: 1