gpt4 book ai didi

Vim 键映射未注册

转载 作者:行者123 更新时间:2023-12-04 22:52:51 25 4
gpt4 key购买 nike

我正在尝试在 Vim 中映射 Alt-r 以保存然后执行当前文件,并映射 Alt-R 以保存然后执行,但允许将额外参数传递给脚本。

在我的 vimrc 中,我有以下内容(文件末尾的键映射):

" Basic setup
set modeline
syntax on
filetype plugin indent on

" Load pathoen
execute pathogen#infect()

" Solarized colourscheme
if has('gui_running')
set background=light
else
set background=dark
endif
colorscheme solarized

" Map Alt-r to run current file as if it were a script
nmap <M-r> :w<CR>:!./%<CR>
nmap <M-R> :w<CR>:!./%<Space>

" Allow Alt-<CursorKey> to move around windows
nmap <M-Up> :wincmd k<CR>
nmap <M-Down> :wincmd j<CR>
nmap <M-Left> :wincmd h<CR>
nmap <M-Right> :wincmd l<CR>

窗口移动的键映射工作正常,但 Alt-r 似乎没有做任何事情,而 Alt-R 将 Vim 置于替换模式。我检查了 :help M^r 和 :help M^R 但他们没有列出任何映射, :map 也没有列出这些键。我也已经在 Gnome 终端中禁用了 Alt 键映射。

有什么建议吗??

最佳答案

这可能是 your terminal emulator which may encode the alt key different from what vim expects 的问题.

Ctrl+v 使 vim(和大多数 shell)逐字(字面)输出下一个字符或组合键。这样,您可以 insert the keycode produced when you press Alt+r directly into your configuration file通过添加

set <M-r>=^[r
set <M-R>=^[R

必须通过按 Ctrl+v 然后按 Alt+x 来输入像 ^[x 这样的转义字符,并且可能会产生一个在不同的终端模拟器上有不同的结果。

请注意,等号周围没有空格。 Vim 会将额外的空格解释为赋值的一部分,这会使指令行为异常。

关于Vim 键映射未注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18632900/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com