← Back to Upcase

How would you do this without Visual Mode?

(Rainer Borene) #1

After using Vim so many years, only now I realize that Visual Mode is, in fact, sort of a “bad smell” (thanks @christoomey for clarifying this).

But my question is how would it be possible to append the same string on the following three lines for example? Using Visual Mode I would do V2jA (only A because I’m using vim-kana niceblock). How would you do that without visual mode?

Btw, It’s liberating to use this on my init.vim:

nnoremap v <nop>
nnoremap V <nop>


(Chris Toomey) #2

Hi @rainerborene, glad you’ve found some useful bits in my vim ramblings!

Just to be super clear, I consider visual mode to be a smell in that it is something that will cause me to take a second look / assume there is likely a better option, but not an indication that something is definitively wrong.

More specifically, I tend to view visual mode & linewise visual mode (v and V respectively) to be code smells as I can almost always find another way to more directly target the characters I want to act on, especially when using custom text objects. Visual block mode, available via <C-v> in normal mode or via the vim-kana niceblock plugin you mention is a more specialized mode that tends to not be easily replaced by text objects or motions, and as such I’m generally fine with visual block mode and use it often.

To your specific question of adding text at the end of three contiguous lines, I’d likely do this via A<text-to-append-here> and then use . to repeat it on the other two lines, but I’d also reach for visual block mode if operating on more than a few lines.

Hope that helps!