简体   繁体   English

无法理解 .vimrc 中的一行

[英]Unable to understand a line in .vimrc

I do not understand what the following line does in .vimrc我不明白以下行在 .vimrc 中的作用

nmap <silent> <leader>v :EditConfig<cr>

It seems that看起来

  • nmap mean noremap nmap 表示 noremap
  • silent seems to mean apparently no beep in Vim沉默似乎意味着在 Vim 中显然没有哔哔声
  • leader seems to mean the first character in the mode :领导者似乎意味着模式中的第一个字符:
  • v seems to mean visual mode v 好像是视觉模式的意思
  • EditConfig should be a command in vim in the mode : (However, it is not.) EditConfig 应该是 vim 中 mode 中的一个命令:(但是,它不是。)

What does the line mean in .vimrc?该行在 .vimrc 中是什么意思?

  • nmap means "map a key sequence when in normal mode" (see vim's docs ). nmap意思是“在正常模式下映射一个键序列”(参见 vim 的文档)。
  • <silent> tells vim to show no message when this key sequence is used. <silent>告诉 vim 在使用这个键序列时不显示任何消息。
  • <leader> means the key sequence starts with the character assigned to variable mapleader -- a backslash, if no let mapleader = statement has executed yet at the point nmap executes. <leader>表示键序列以分配给变量mapleader的字符开始——反斜杠,如果在nmap执行点还没有执行let mapleader =语句。

And the v is the rest of the key sequence.v是键序列的其余部分。

So overall this is mapping, in normal mode, a backslash-v key sequence to show no message and execute :EditConfig which is likely a function defined previously in the vimrc to edit configuration files (see for example this vimrc, search in browser for editconfig).所以总的来说这是映射,在正常模式下,反斜杠-v 键序列不显示任何消息并执行:EditConfig这可能是之前在 vimrc 中定义的用于编辑配置文件的函数(参见例如这个vimrc,在浏览器中搜索 editconfig )。 :call EditConfig() at the end (as the vimrc file I gave the URL to uses) would be better, I believe. :call EditConfig()最后(作为我给使用的 URL 的 vimrc 文件)会更好,我相信。

It would appear that you are missing a function...看起来你缺少一个功能......

Try,尝试,

function! EditConfig()
    for config in ['$MYGVIMRC', '$MYVIMRC']
        if exists(config)
            execute 'edit '.config
        endif
    endfor
endfunction

Check this example . 检查这个例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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