1

I have this in my .vimrc as global for gf: map gf :edit <cfile><cr> from the help on gf, but I want to remap gf in markdown files for a plugin command with the following:

autocmd FileType markdown nnoremap <buffer>gf <Plug>Markdown_EditUrlUnderCursor

When running :nmap I see the following output:

n  ge           @<Plug>Markdown_EditUrlUnderCursor
n  gx           @<Plug>Markdown_OpenUrlUnderCursor
n  gf          *@<Plug>Markdown_EditUrlUnderCursor

but gf doesn't do what it should. I see the little star there and I guess it has something to do with it, but I have no idea what that means. ge works as expected. How can I achieve what I want?

1 Answer 1

1

When you want to map a <Plug> mapping always use nmap not nnoremap.

Basically a <Plug>(Something) is a sequence of chars that are mapped to some functionality.

Imagine you have:

" you have some mapping
nnoremap a :echo "hello"<CR>
" and want remap that mapping
nmap b a

" same
nnoremap asdf :echo "world"<CR>
nmap b asdf

" same
nnoremap <Plug>(hello) :echo "hello world"<CR>
nmap gf <Plug>(hello)
2
  • I tried with nmap afterwards, but it seems vim has already saved the bad map and would not overwrite, so that's where my confusion came from.
    – fbence
    Jan 13 at 14:04
  • Just as a note for other people: deleting ~/.vim/view removes these old configs.
    – fbence
    Jan 13 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.