Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.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
在vim中“如何映射”;“保存”;按ctrl-s键_Vim - Fatal编程技术网

在vim中“如何映射”;“保存”;按ctrl-s键

在vim中“如何映射”;“保存”;按ctrl-s键,vim,Vim,在vim中,如何将“save”(:w)映射到ctrl-s 我正在尝试“映射”命令,但当我按下ctrl-s时,xterm冻结 如果我给ctrl-v,ctrl-s,我仍然只能看到一个^,而不是^sctrl+s是终端停止更新的常用命令,这是一种降低输出速度的方法,因此您可以在没有回滚缓冲区的终端上读取它。首先确定是否可以将Ctrl+S传递给应用程序。然后这些映射命令将起作用: noremap <silent> <C-S> :update<CR> v

在vim中,如何将“save”(
:w
)映射到ctrl-s

我正在尝试“映射”命令,但当我按下ctrl-s时,xterm冻结

如果我给ctrl-v,ctrl-s,我仍然只能看到一个
^
,而不是
^s

ctrl+s是终端停止更新的常用命令,这是一种降低输出速度的方法,因此您可以在没有回滚缓冲区的终端上读取它。首先确定是否可以将Ctrl+S传递给应用程序。然后这些映射命令将起作用:

noremap <silent> <C-S>          :update<CR>
vnoremap <silent> <C-S>         <C-C>:update<CR>
inoremap <silent> <C-S>         <C-O>:update<CR>
noremap:更新
vnoremap:更新
inoremap:更新

顺便说一句:如果Ctrl+S冻结了您的终端,请键入Ctrl+Q使其再次运行。

在linux with VI中,您希望按Ctrl-S并让它保存您的文档。这对我很有效,在.vimrc文件中放入以下三行。此文件应位于您的主目录中:
/home/el/.vimrc
如果此文件不存在,您可以创建它

:nmap <c-s> :w<CR>
:imap <c-s> <Esc>:w<CR>a
这样做的目的是关闭Ctrl-S的绑定,并在按下Ctrl-S时清除屏幕上的任何XOFF消息。注意,在更改.bash_配置文件后,必须使用命令“source.bash_profile”或注销/登录重新运行它

更多信息:

Mac OSX终端+zsh? 在您的.zprofile中 为什么?发生了什么事?请参见,但基本上对于大多数终端而言,ctrl+s已经用于某些功能,因此这个别名是vim,以便在运行vim之前关闭该映射

在你的
nmap:w
imap:wa
为什么?发生了什么事?这一点应该很明显,我们只是将ctrl+s映射到不同的击键,这取决于我们处于正常模式还是插入模式。

vim

# ~/.vimrc
nnoremap <c-s> :w<CR> # normal mode: save
inoremap <c-s> <Esc>:w<CR>l # insert mode: escape to normal and save
vnoremap <c-s> <Esc>:w<CR> # visual mode: escape to normal and save
bash(如果使用)


维姆的老毛病是什么:w?我猜ctrl-s会冻结xterm,因为它会冻结终端中的所有输出。('stty-ixon'可能会有帮助)按(Escape-shift-colon-w-Enter)比按Ctrl-s大约需要3倍的时间。虽然我发现按ctrl-s键比按Esc-shift-colon-w-enter键更容易导致腕管疼痛,但它会分散压力,让人有两种选择可以挽救。在经历了数年的冻结我的vi会话之后。。。ctrl qFor gnome terminal向my.bashrc添加'stty-ixon'就足够了。:imap:wa您能解释一下为什么使用2
imap
命令吗?似乎您只需要
imap:wa
。谢谢。我原以为第二个imap命令行有意义,但经过进一步检查,它没有任何作用。很好的捕获,我删除了蹩脚的行。你为什么使用a而不是I?当你在你的.zshrc文件“stty-ixon”中包含“stty-ixon”时,可以使用OSX、iTerm2、ZSH、噢,我的ZSH。对于带有bash的Terminal.app,bashrc也是必需的。@ned batchelder如果你映射到Ctrl-W,可以吗?vim或终端默认命令是否有问题?@ThiG
通常用于窗口拆分和窗口命令顺便说一句,这是搜索引擎将我放在这里的原因,谢谢。它不应该是
vnoremap:w#视觉模式:逃逸到正常状态并保存
?您救了我一天
alias vim="stty stop '' -ixoff; vim"
nmap <c-s> :w<cr>
imap <c-s> <esc>:w<cr>a
# ~/.vimrc
nnoremap <c-s> :w<CR> # normal mode: save
inoremap <c-s> <Esc>:w<CR>l # insert mode: escape to normal and save
vnoremap <c-s> <Esc>:w<CR> # visual mode: escape to normal and save
# ~/.zshrc
# enable control-s and control-q
stty start undef
stty stop undef
setopt noflowcontrol
# ~/.bash_profile or ~/.bashrc
# enable control-s and control-q
stty -ixon