On Saturday, March 3, 2012 12:07:18 PM UTC-6, Tarlika Elisabeth Schmitz wrote: > > If I want to map a function onto the same key in any mode, is this the > best way of doing it? : > > map <silent> <F6> :nohlsearch<CR> > imap <silent> <F6> <Esc>:nohlsearch<CR>i >
Some suggestions: * For insert mode, a better way would probably be <C-O> instead of <Esc>...i * Use nnoremap and xnoremap instead of just "map" which gets normal, operator-pending, and visual modes. You probably want to use a <C-U> in the visual mode mapping to remove the range, and you probably don't want to do it at all in operator-pending mode. * Either use inoremap, or keep using imap but simply use the normal-mode mapping instead of re-defining it on the RHS For example: nnoremap <silent> <F6> :nohlsearch<CR> xnoremap <silent> <F6> :<C-U>nohlsearch<CR> imap <silent> <F6> <C-O><F6> Other than that...it should work fine the way you have it. > -- 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
