Tuesday, March 2, 2010

Re: put html tags around selected text

Hey Kai!

On Mon, Mar 1, 2010 at 7:47 PM, <vimml@selgrad.org> wrote:
> Line 2 first jumps to the start of the selection, (`<) enters insert
> mode (i) and inserts "<!--". The explicit use of \<esc> is necessary to
> get out of insert mode (or so I think).
> The conditional is used because if the end of the selection is on the
> same line as is the start of the selection then the last character you
> selected will be 4 steps to the right of the original selection, because
> the string "<!--" has been inserted before. As you can see, the only
> difference of the commands in the body of the if/else is the 4l, which
> moves the cursor 4 steps to the right.
> The a is for append which inserts "-->" after the cursor position (which
> in this case is after the originally selected character), and somehow
> doesn't need "\<esc>" at the end. Maybe this isn't necessary in line 2
> either. I'm no vimscript expert ;)

The following works fine for me.
---------------------------------------
function! Blub() range
echo "hallo"
exec "normal `>a-->"
exec "normal `<i<!--"
endfunction
---------------------------------------

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