Wednesday, September 28, 2011

Re: Is there a way to mimic textmate's "wrap each selected line in open/close tag" ?

On 09/28/11 07:52, Amitava Shee wrote:
> I have starting using the excellent surround.vim plugin. Is there a way to
> mimic textmate's "wrap each selected line in open/close tag" ?

if you're doing whole lines, I do this infrequently enough that I
just use

:'<,'>s!.*!<tag>&</tag>

which will operate on the highlighted lines or

:g/pattern/s!.*!<tag>&</tag>

to operate on lines matching "pattern". However, if you do it
frequently or need to operate on partial lines, you can investigate

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

I can't say I've used it, but it's the #1 answer given anytime
anybody asks a question like yours, so it seems to have a lot of
happy users :)

> Also, I am viws" does not wrap the word with " - instead it deletes the word
> and puts you between "". viwS" seems to do the right thing. Is this correct
> behaviour?

I'm not sure what behavior you're expecting here, as

viws"

should visualize the inner word, delete it, leave you in insert
mode where your double-quote appears. OTOH,

viwS"

visualizes the inner word, then deletes the entire line (except
leading whitespace, depending on your indentation settings),
leaves you in insert mode, where your double-quote appears. If
you get behavior different from either of these, you likely have
some mapping interfering that you'd have to track down.

-tim


--
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: