> First, your mapping command is missing a left-hand-side. You need to
> tell Vim what you want to press to trigger your mapping. E.g. nmap
> <F5> :echo 'foo'<CR> if you want to press the <F5> key to echo the
> text "foo" on your screen.
>
> Second, since you're starting from normal mode, you need to finish off
> your ex command with a <CR> or the equivalent <Enter>.
>
> Remember mappings are telling Vim to execute each character basically
> as if you typed them in yourself. You need to press <Enter> to finish
> executing a search manually, so your mapping needs to do this as well.
>
> Two suggestions, however:
>
> 1. Use nnoremap instead of nmap to avoid accidentially triggering any
> mappings while executing your mapping.
> 2. Use an expression mapping, which would allow you to eliminate the
> exe altogether. See :help :map-<expr>.
>
Thank you Ben. Interestingly, I had to move the cursor over two
places, which is one more than I did when typing the commands by hand.
Here is the final result:
nnoremap <F5> 0f- :exe '/^.\{'.(col(".")-2).'\}-'<CR>
I learned a lot from your post, especially regarding nnoremap. Thank
you for your help!
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
--
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:
Post a Comment