映射参数之间有什么区别?

时间:2017-01-04 15:16:15

标签: vim mapping vi vim-plugin

输入之间的实际差异是什么:

  1. - willRotateToInterfaceOrientation:duration: - willAnimateRotationToInterfaceOrientation:duration: - didRotateFromInterfaceOrientation:

  2. :map <script> , dd

  3. :map , dd

  4. :map <buffer> , dd

  5. 我更关注:map <script> <buffer> , dd个论点。在哪些情况下,我们需要使用参数<script>

2 个答案:

答案 0 :(得分:1)

简而言之,缓冲区位于文件的mem文本中,您可以通过:ls查看并编辑。 脚本也可以由vim加载,但是你无法在:ls命令中看到它。例如,你创建了vim文件,比如foo.vim

 function! s:SayHi() abort 
      echo "Hi, there"
 endfunction 

vimrc文件中,您获取foo.vim,现在有一个脚本范围。与<script>的映射将使{rhs}调用其他映射,在同一脚本中定义,即使使用nnoremap也是如此。

一个例子也许更好。说同样的foo.vim,我们有两个映射:

nnoremap <SID>foo dowhatever 
nnoremap abc <SID>foo

这样,由于abcdowhatever最终不会转到nore。然而

nnoremap <SID>foo dowhatever 
nnoremap <script> abc <SID>foo 

这将覆盖nore规则,abc将覆盖dowhatever。但仅当第一个映射在同一个脚本中定义时。 (nnoremap <script>nmap <script>正在做同样的事情)

我个人认为<script>地图确实没用。

答案 1 :(得分:1)

A&#34;脚本&#34;是一组相关的Ex命令和vimscript函数放在一个*.vim文件中。

启动时,Vim会提供许多&#34;脚本&#34;。这意味着它执行每个脚本中的每一行,就像您自己在命令行中编写它一样。此外,Vim通过<SID>机制跟踪源自何处。 &#34;脚本&#34;由Vim在内部使用,以提供其他功能。

<script>中明确解释了:h <script>参数的含义:

  

如果其中一个命令的第一个参数是&#34; <script>&#34;它习惯了   定义新的映射或缩写,映射只会重新映射字符   在{rhs}中使用在脚本本地定义的映射,从。开始   &#34; <SID>&#34 ;.这可以用于避免脚本外部的映射   干扰(例如,在mswin.vim中重新映射CTRL-V时),但确实使用其他   脚本中定义的映射。

A&#34;缓冲区&#34;是文件内容的内存中表示。把它想象成一个&#34;文件&#34;在常规课程中。

编辑&#34;缓冲区&#34;并且您定义了<buffer>映射,该映射仅在该特定缓冲区中可用。

继续你的例子:

" - remapping is possible but only with other
"   mappings defined in the same script
:map <script> , dd

" - mapping is global
" - remapping is possible
:map , dd

" - mapping is buffer-local
" - remapping is possible
:map <buffer> , dd

" - mapping is buffer-local
" - remapping is possible but only with other
"   mappings defined in the same script
:map <script> <buffer> , dd
相关问题