Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 将密钥重新映射到<;电子稳定控制系统>;不';我不能在命令模式下工作_Macos_Vim_Remap - Fatal编程技术网

Macos 将密钥重新映射到<;电子稳定控制系统>;不';我不能在命令模式下工作

Macos 将密钥重新映射到<;电子稳定控制系统>;不';我不能在命令模式下工作,macos,vim,remap,Macos,Vim,Remap,我在成功地将密钥重新映射到时遇到一些问题。我已经用多个字符尝试过了,所以假设我想将1重新映射到。在我的.vimrc文件中,我添加了以下行: noremap! 1 <Esc> 将显示“searchtext”的搜索结果,而不是在不搜索的情况下退出回到正常模式。同样,对于以开头的命令:。有解决办法吗?我是否使用了错误的映射功能 我正在从终端使用Vim,尽管在MacVim GUI上测试后,它也有这个问题。根据文档,这是预期的行为。它是vi兼容性的一部分 如果您查看:hi_esc |/*3

我在成功地将密钥重新映射到
时遇到一些问题。我已经用多个字符尝试过了,所以假设我想将
1
重新映射到
。在我的
.vimrc
文件中,我添加了以下行:

noremap! 1 <Esc>
将显示“searchtext”的搜索结果,而不是在不搜索的情况下退出回到正常模式。同样,对于以
开头的命令:
。有解决办法吗?我是否使用了错误的映射功能


我正在从终端使用Vim,尽管在MacVim GUI上测试后,它也有这个问题。

根据文档,这是预期的行为。它是vi兼容性的一部分

如果您查看
:hi_esc |/*3 Go
,您将看到以下段落

*3 Go from Command-line mode to Normal mode by:
   - Hitting <CR> or <NL>, which causes the entered command to be executed.
   - Deleting the complete line (e.g., with CTRL-U) and giving a final <BS>.
   - Hitting CTRL-C or <Esc>, which quits the command-line without executing
     the command.
   In the last case <Esc> may be the character defined with the 'wildchar'
   option, in which case it will start command-line completion.  You can
   ignore that and type <Esc> again.  {Vi: when hitting <Esc> the command-line
   is executed.  This is unexpected for most people; therefore it was changed
   in Vim.  But when the <Esc> is part of a mapping, the command-line is
   executed.  If you want the Vi behaviour also when typing <Esc>, use ":cmap
   ^V<Esc> ^V^M"}
*3通过以下方式从命令行模式转到正常模式:
-点击或,导致执行输入的命令。
-删除整行(例如,使用CTRL-U键)并给出最终结果。
-点击CTRL-C或,这将退出命令行而不执行
命令。
在最后一种情况下,可能是使用“wildchar”定义的字符
选项,在这种情况下,它将启动命令行完成。你可以
忽略该选项,然后再次键入。{Vi:点击命令行时
这对于大多数人来说是意外的,因此它被改变了
在Vim中,但当是映射的一部分时,命令行是
已执行。如果您想在键入时也使用Vi行为,请使用“:cmap”
^V^V^M“}
{Vi:…}
开头的部分讨论了Vi兼容性,并解释了您看到的行为


映射
:noremap!1
会做你想做的事。这是完全删除当前行。这是列表中的项目符号2。

我最喜欢的是在所有模式下映射Alt空间以转义。为了实现这一点,我将其放在我的vimrc中:

noremap <a-space> <esc>
inoremap <a-space> <esc>
cnoremap <a-space> <c-u><bs>
noremap)

当您尝试时会发生什么?该命令的执行就像我点击
一样。在这种情况下
是否等同于
?只使用一个序列似乎更优雅,但有副作用吗?我需要将映射拆分为单独的
inoremap
cnoremap
映射(因为删除刚才插入的行并单击backspace都不会离开插入模式,而且会产生相反的效果)。
noremap <a-space> <esc>
inoremap <a-space> <esc>
cnoremap <a-space> <c-u><bs>