How Vim's visual mode has wound up being useful for me
Since discovering Vim's visual (selection) mode I've found myself using it periodically, as I mentioned in passing recently. There have turned out to be a common circumstance I use it in and a second, rather less common case. More specifically, there is a common case for line-wise visual mode selection and a less common case where I reach for block-wise visual mode selections.
The common case for line wise visual selection is selectively
reflowing quoted text in email messages. I'm a long time user of
the very nice par
command
(also, and), which does a great job
of reflowing quoted text, even multiply-quoted text, but you have
to select how much you want to reflow. In my normal way of reflowing
text, I reflow by selecting the paragraph
with '}
', but in my normal Vim setup using this on quoted text will
reflow the entire block of quoted text. In other words, suppose I have:
> Some quoted text in a paragraph that I > do want to reflow. This can run on. > > Tabular data to not reflow > some data points > more stuff
If I use '}
' to select the entire 'paragraph' I'll reflow both
sections. So what I do here is make a line-wise visual mode selection
of just the first chunk and run it through par
to reflow it. This
case comes up surprisingly often, although there are probably Vim
options I could set to make disturbingly smart about what a paragraph
is.
Where I've found myself using block mode selection is where I have a prefix I want to remove or add to some lines, but the lines are already embedded in some other form of quoting at the start of the line. Unfortunately I haven't needed to do this recently enough to remember a real example, but suppose we have something like:
" abc more and more " def stuff that is " ghi going on
For whatever reason, I want to remove, insert a prefix, or otherwise manipulate the middle column (the 'abc', 'def', and 'ghi'). So I make a visual block selection, narrowing the scope of what I'm going to do to just the column, and then I can apply the change operation I want.
This sort of 'edit in the middle' can come up in editing configuration files, although unfortunately I can't remember the specific case where I first realized that visual block mode was the way to do what I wanted.
(I suspect I'll find other uses for visual mode over time. The comments on my first entry have some useful suggestions.)
|
|