Hi,
Chris Lott schrieb am 10.10.2018 um 21:05:
>
> I have a mapping in my .vimrc :
>
> nnoremap <leader>md :write<CR><bar>:silent !open -a 'Marked.app' '%:p'<CR>
>
> When I invoke the map, my cursor in Vim moves to the beginning of the
> line. This doesn't happen if I run the commands manually. Why does the
> cursor move and how can I stop it from doing so?
the problem is with the combination of <CR> and <bar> in your mapping.
The <CR> will execute the :write command. After that Vim is in normal
mode, where <bar> is a command to put the cursor in a specified column,
i.e. 10| would put the cursor in column 10. Because <bar> stands on its
own in your mapping the cursor is put in the first column.
You only need either <CR> or <bar> between two commands on the right side
of your mapping. You can write it either as
nnoremap <leader>md :write<bar>silent !open -a 'Marked.app' '%:p'<CR>
or as
nnoremap <leader>md :write<CR>:silent !open -a 'Marked.app' '%:p'<CR>
Regards,
Jürgen
--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wednesday, October 10, 2018
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment