Tuesday, September 7, 2010

Re: vim equivalent of save-excursion in emacs

On Tue, Sep 07, 2010 at 11:47:03AM +0200, Oivvio Polite wrote:
> I came up with this mapping to reformat the current paragraph
>
> imap <leader>. <Esc>{V}!par<CR>i
>
> when the command is done the cursor will be at the beginning of the
> paragraph rather than where ever it was when the command was issued.
>
> In emacs I solve this with save-excursion. What do I do in vim?

Ok, I figured out that "bookmarks" are how you do it in vim.
ma sets the bookmark a to the current cursor postion
`a moves the cursor to the bookmark a

So my mappings for paragraph reformating with par are now:

nmap <leader>. ma{V}!par<CR>`a
imap <leader>. <Esc>ma{V}!par<CR>`ai


oivvio

--
http://pipedreams.polite.se/about/


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