I'm trying to get Ctrl-S to save, but vim doesn't seem to be picking up any mappings with the control character. None of these work:
inoremap <C-S> <Esc>:update<Enter>
map <C-S> <Esc>:update<Enter>
nnoremap <C-S> <Esc>:update<Enter>
What's going on with the control key? How can I fix it?
Edit: The answers here don't work for me.
I tried stty stop ^-
and stty -ixon
, which finally let the signal come through to vim, but the mapping still won't get picked up in insert mode. So now it seems like it's only insert mode that's causing problems.
Other mappings with Ctrl in insert mode also don't work:
inoremap <C-g> <C-O>:update<CR>
Solution: The issue arose because I had set paste
in my vimrc. Removing that line solved the problem. Still not sure why.
答案 0 :(得分:2)
流量控制可能处于活动状态,这会阻止Vim看到<C-s>
序列。如果是这种情况,您可以在.bash_profile
/ .zshrc
中使用类似的内容关闭流量控制:
stty -ixon
答案 1 :(得分:0)
看起来你在不离开插入模式的情况下尝试保存。给它一个机会,它对我有用。
@RequestMapping(method= RequestMethod.POST, value = "/deleteName")
public String deleteName(@Valid @ModelAttribute("testResult") TestResult testResult, BindingResult bindingResult, Model model, HttpServletRequest request) {
System.out.println(testResult.toString());
return "/";
}
答案 2 :(得分:0)
这是因为我的vimrc中有set paste
。我仍然不明白为什么,但看起来删除那条线解决了它。
不知道如何解决这个问题。