On 2007-05-14, "John R. Culleton" <[EMAIL PROTECTED]> wrote:
> Gary wrote in part:
>
> nmap <silent> <F2> :call DoSub()<CR>
>
> function DoSub()
> %s/^"/``/e
> %s/ "/ ``/ge
> %s/"$/''/e
> %s/" /'' /ge
> endfunction
>
> For my other F keys I have used noremap instead of nmap, thus:
> inoremap <F3> <C-O>:!pdftex book.tex<Cr>
> nnoremap <F3> :!pdftex book.tex<Cr>
> inoremap <F4> <C-O>:!texexec book.tex >/dev/null<Cr>
> nnoremap <F4> :!texexec book.tex >/dev/null<Cr>
> inoremap <F5> <C-O>:!acroread book.pdf<Cr>
> nnoremap <F5> :!acroread book.pdf<Cr>
> nnoremap <F2> 1GgqG
>
> Which is the better usage? I have read but do not understand fully
> the "help" item suggested previousely.
Without the "nore" part, when the use presses the mapped key, vim
executes the rhs of the mapping including executing any mappings it
finds on the rhs. For example, if you define the following mapping,
nmap D dj
to delete the current line and the line below, and some plugin has
redefined 'j' with
nmap j k
then when you type 'D', your macro will delete the current line and
the line _above_.
Adding "nore" tells vim to ignore any mappings on the rhs and to
execute any commands on the rhs with their default actions.
Continuing the example above, changing the 'D' mapping to
nnoremap D dj
will ensure that (as long as D itself is not remapped) typing 'D'
will delete the current line and the line below regardless of any
mapping of 'd' or 'j'.
Including "nore" is then the safer usage since it protects the rhs
of the macro from being affected by any mappings of the functions on
the rhs. I didn't use 'nnoremap' in the <F2> mapping above because
I thought there was no possibility of a remapping of anything on the
rhs, so that the "nore" would be superfluous, but now I see that the
macro would be affected if someone defined ':' as a macro (a really
poor choice).
Regards,
Gary
--
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Mobile Broadband Division
| Spokane, Washington, USA