Gerald Lai wrote:
On Thu, 15 Jun 2006, Sylvain wrote:
[snip]
I'm using setline() function to replace the line..so I will delete it
before I add mine, it's not very elegant so if anyone has a better
way, I will take it also :-)
[snip]
I modified Vimtip#329 some time ago to be able to swap visual
highlighted words. I also modified it into a function form because it
got long.
The code below has an advantage over tip#329 in that it does not pollute
the search history. In addition, it also works for swapping words on
different lines.
It does, however, clobber marks 'y & 'z for positioning purposes. You
can code around this if you want.
Sounds like your function does something like what visswap.vim does, which
is mentioned in the notes following tip#329. It, too, does not pollute
the search
history, nor does it clobber marks. Its actually swaps visual blocks,
not just
words (but, of course, it can swap words, too). And, its a function! :)
The procedure: use visual block to select a block; type ctrl-y (sort
of a yank)
Then, use visual block to select the other block; type ctrl-x
(do the swap)
visswap.vim is available at
http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs,
see "Visual Mode Based Swapping".
Regards,
Chip Campbell