Sunday, October 28, 2012

Re: surround a visual block with character(s)

On 10/28/12 12:47, Chris Lott wrote:
> In other words, I often want convert this:
>
> blah blah foo foo
>
> to
>
> "blah blah foo foo"
>
> I assume there are plugins that help with this kind of thing,

The most common is Tim Pope's surround.vim

http://www.vim.org/scripts/script.php?script_id=1697

> but I'm curious how to do this most efficiently without them.

There are a sufficient number of edge cases that I'd suggest using a
plugin to worry about them for you. In your particular use-case,
it's only one character, and it's the same character on both sides.
Things get a lot uglier when you have an opening that differs from
your closing (e.g. "smart quotes); if you plan to insert longer
text; if you want to reflow the contents if it causes a rewrapping;
or if your text-to-surround is indented (prevents some solutions,
unless you toggle 'paste' settings); etc.

-tim (not Pope)




--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment