[英]vimrc mapping problem; execute python script mapping not working from vimrc
grr. GRR。 I'm struggling with Vim's learning curve.
我正在努力学习Vim的学习曲线。
And trying to get a simple mapping in my vimrc to execute the current buffer's python script. 并尝试在我的vimrc中获取一个简单的映射来执行当前缓冲区的python脚本。 The mapping is well-formed and works after I enter it into the command line in Vim.
映射格式正确,并在我将其输入Vim中的命令行后工作。 This is the mapping:
这是映射:
map <buffer>
<Se>
:w <CR>
:!usr/bin/env python % <CR>
But it won't load from my vimrc :( I'm using the basic .vimrc_sample with only this mapping appended. What's weird is that I could get a different mapping working from the vimrc: 但它不会从我的vimrc加载:(我使用的是基本的.vimrc_sample,只附加了这个映射。有什么奇怪的是我可以从vimrc获得不同的映射:
map
<St>
itest <Esc>
This one works, but not the script executer? 这个可行,但不是脚本执行者吗? What gives?
是什么赋予了?
Ubuntu 10.10 Python 2.6 Vim 7.2 Ubuntu 10.10 Python 2.6 Vim 7.2
Help is very appreciated! 非常感谢帮助!
I suspect that you have something before map
: <buffer>
argument means that mapping is defined for current buffer only, so adding it to vimrc without something like autocmd FileType python
before it is weird. 我怀疑你在
map
之前有一些东西: <buffer>
参数意味着只为当前缓冲区定义了映射,所以在没有类似autocmd FileType python
类的东西之前将它添加到vimrc是很奇怪的。 Maybe it is the reason why it does not work: you somehow switch to another buffer before testing this mapping. 也许这就是为什么它不起作用的原因:你在测试这个映射之前以某种方式切换到另一个缓冲区。
Some additional things to concern: 还有一些需要注意的事项:
map
where can use noremap
instead. noremap
map
。 <Cu>
before w
) and select modes, and definitely don't want it to be defined for operator-pending modes, so use nnoremap
. w
之前没有<Cu>
)和选择模式,并且绝对不希望为操作员挂起模式定义它,因此请使用nnoremap
。 <Se>
and E
are equivalent. <Se>
和E
是等价的。 w
and !...
in one command using pipe symbol: :w | !/usr/bin/env python %<CR>
:w | !/usr/bin/env python %<CR>
在一个命令中组合w
和!...
:w | !/usr/bin/env python %<CR>
. :w | !/usr/bin/env python %<CR>
。 usr
. usr
之前忘记了斜线。 Jesus, Murphy's Law. 耶稣,墨菲定律。
After searching for an answer for an hour, 1 min after posting this q I solved it. 在搜索了一个小时的答案后,发布此q后1分钟我解决了它。 The problem was
<buffer>
in the mapping. 问题是映射中的
<buffer>
。
Removing it made the mapping work, thus: 删除它使映射工作,因此:
nnoremap E w:
<CR>
:!python % <CR>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.