This is best explained with an example: Suppose I want to remap G
to go to the end of the line, as I find that convenient. I also want to be able to jump to the end of the file, maybe by pressing gG
. I might then try the following:
nmap gG G
nmap G g_
However, that'll not work. Since G
was remapped to g_
later on, the action performed by gG
will not be to go to the end of the file, but the end of the line.
So my question is: Is there a way to "fix" the mapping, so its actions are not affected by later remappings of the keys it uses?
Note: I know the problem above can be solved by other methods, such as using nmap <silent> gG :$<cr>
. My question is not about solving that specific problem, but more about whether the idea proposed above is possible in vim.
:nnoremap gG G
:nnoremap
only prevented recursion, thanks. Is this question too obvious and should be deleted? If so, feel free to suggest that, if not, feel free to leave your comment as an answer.