I was trying to append some text to multiple lines in vi on a RHEL 6 system, however I could not get it to work. I press Control + V to get into visual block mode, select the lines I need, but when I press capital A, instead of going into insert mode, it goes back into command mode. I then created two droplets on digital ocean to test this, one CentOS 7 and one Ubuntu, and to my surprise, this worked fine on Ubuntu, but did not on CentOS. So why is that? Is there some option I need to add to my vimrc file or are these functions remapped somehow on RHEL/CentOS? Searching the web did not help very much.
1 Answer
It appears to be a result of inconsiderate overcustomization by RedHat somewhere in /usr/share/vim .
The following workaround
vim -u NONE [file ...]
suppresses all initializations (replace NONE by the path to your own .vimrc to do your own initialization). After this, block commands work fine for me. Consider setting a shell alias if you routinely need this. See vim's man page for details.
-
1Welcome to Vi and Vim! If you can share what specific changes are in
/usr/share/vim
that cause this, it would improve the answer—and possibly illuminate a less nuclear way to solve the problem.– D. Ben Knoble ♦Commented Feb 3, 2021 at 16:01 -
Thanks for asking. On one of my CentOS 7 systems,
cd /usr/share/vim/vim74 && find . -type f -print | xargs cat | wc -l
reveals that there are more than 300000 lines of customization, making this a search for a needle in a haystack.Generally I doubt the value of vendor-supplied customization for the end-user because vendor lock-in reduces the user's ability to confidently use their tools across a wide variety of OSs (speaking from 35 years of professionally using vi/vim as preferred editor) Commented Feb 10, 2021 at 10:05
+visualextra
(which is now always included with the latest Vim versions, but I believe a tiny Vim does not enable this by default)