简体   繁体   中英

Can I make a Vim mapping for a single file?

Basically I would like to be able to quickly look up Vim's help pages for specific commands. To do that, I am using this mapping:

nnoremap K :help <C-r><C-w><CR> 

However, I would like to apply this mapping only to my .vimrc (in order to be able to use different lookup documentations for different files).

Is that possible?

K already does keyword lookup but the associated 'keywordprg' option is rarely defined.

Add the snippet below to your ~/.vimrc to get the desired behavior:

augroup vim
    autocmd!
    autocmd FileType vim setlocal keywordprg=:help
augroup END

Thanks for reminding me to set it up correctly in my own config.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM