vim - VIM:退格键在正常模式下删除,但在插入模式下不执行任何操作。
问题描述
初步信息:
- 问题出在终端 Vim,而不是 gVim
- 我使用 CMDER(基于 conemu)作为我的终端仿真器
- 我在 Windows 10 上
详细说明:
当我处于插入模式时,我可以正常输入文本,但退格键不起作用。在正常模式下,退格键删除文本。这与我今天早些时候的行为完全相反。我在网上阅读了许多其他描述 Vim 非正统退格行为的帖子,但建议的配置设置(即 bs=2 或 bs=indent,eol,start)什么也没做。
更不寻常的是 gVim 的行为“正常”,即:退格键在正常模式下将光标向左移动,并在插入模式下删除文本。
我想要的是退格键在插入模式下删除文本(就像大多数其他程序一样)并在正常模式下导航/禁用。我怎样才能恢复这种行为?
下面是我的 _vimrc 的副本:(我会把它放在 github 上,但我的 git 目前搞砸了,我还没有修复它。)此外,默认情况下,_vimrc 内部还有一个函数。我不知道它做了什么,但为了节省空间而省略了它。如果你想看看我是否可以在回复中发布它。
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
" Pathogen - Plugin manager
execute pathogen#infect()
set nocompatible " Turns off Vi compatability gubbinz
" Color Theme
if !has("gui_running") " Allows some 256 color themes to work in Terminal
set term=xterm
set t_Co=256
let &t_AB="\e[48;5;%dm"
let &t_AF="\e[38;5;%dm"
colorscheme gruvbox
endif
let g:gruvbox_dark_contrast = 'hard' " Both of these are just visual gruvbox tweaks
let g:gruvbox_light_contrast = 'hard'
set guifont=Consolas:h10:cANSI:qDRAFT " Changes font
set bs=indent,eol,start " Makes backspace be normal
set filetype=ON " Has vim check for filetype
set showcmd " Displays incomplete commands
set ruler " Shows position of cursor in document
set syntax=ON " Turns on syntax highlighting
set number " Show line numbers
set linebreak " Break lines at word (requires Wrap lines)
set showbreak=+++ " Wrap-broken line prefix
set textwidth=100 " Line wrap (number of cols)
set showmatch " Highlight matching brace
set hlsearch " Highlight all search results
set smartcase " Enable smart-case search
set incsearch " Searches for strings incrementally
set autoindent " Auto-indent new lines
set shiftwidth=4 " Number of auto-indent spaces
set smartindent " Enable smart-indent
set smarttab " Enable smart-tabs
set softtabstop=4 " Number of spaces per Tab
set undolevels=1000 " Number of undo levels
set backspace=indent,eol,start " Backspace behaviour
set go=egrLTm " Changes flags that specify how the GUI loads
解决方案
最有可能的是,您的插入模式退格键被映射为什么都不做(即<nop>
)。通过键入来验证这一点:verbose imap <bs>
。这将显示退格键是否已映射以及映射的设置位置。
我想要的是退格键在插入模式下删除文本(就像大多数其他程序一样)并在正常模式下导航/禁用。我怎样才能恢复这种行为?
你可以做:
iunmap <bs>
nnoremap <bs> <nop>
第一行在<bs>
插入模式下取消映射,因此<bs>
将恢复其默认功能。第二行在<bs>
正常模式下映射什么都不做。
推荐阅读
- r - R fOptions 的 MonteCarloOption 模拟器中的反义词有什么作用?
- json - ExpoAppAuth + Instagram 错误:ExpoAppAuth.Get Auth:JSON 反序列化错误
- javascript - Koa 会话根据请求创建新会话?
- excel - 应用程序定义或对象定义错误 - 无法解决
- html - How can I position my hamburger menu and its drop down on the right side at the same time with bootstrap?
- android - 找到Android sdkmanager 工具,但运行失败
- arrays - Ruby - 将 Object.class 测试为数组的问题
- linux - systemctl 服务在启动命令上挂起,在 journalctl 中没有日志
- javascript - 模拟输入字段 VANILLA Javascript 中的键
- python - VSCODE Python虚拟环境未显示