macos Mac 终端 Vim 只会在行尾使用退格键

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3534028/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:10:11  来源:igfitidea点击:

Mac terminal Vim will only use backspace when at the end of a line

macosvimterminal

提问by cflewis

I seem to have something odd with either my Mac 10.6 terminal or my .vimrc.

我的 Mac 10.6 终端或.vimrc.

When I type backspaceon my laptop's keyboard, it only works when the cursor is at the end of the line. Trying to delete from within a line does nothing. MacVim operates normally. Google hasn't helped because I can't even figure out what to call this behavior.

当我backspace在笔记本电脑的键盘上打字时,它仅在光标位于行尾时才起作用。尝试从一行中删除没有任何作用。MacVim 运行正常。谷歌没有帮助,因为我什至不知道如何称呼这种行为。

All other backspace commands in my Terminal work as expected, so I am leaning towards it being Vim specific.

我的终端中的所有其他退格命令都按预期工作,所以我倾向于它是 Vim 特定的。

Here's the output of my ~/.vimrc 's mappings, I can't see anything that would make Vim in the terminal operate this way:

这是我的 ~/.vimrc 映射的输出,我看不到任何会使终端中的 Vim 以这种方式运行的内容:

cflewis@coral-reef ~> egrep ".*map.*" ~/.vimrc 
"inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
let mapleader = ","
map Q gq
nmap <silent> <leader>s :set nolist!<CR>
" extended '%' mapping for if/then/else/end etc
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>
nmap <silent> <C-N> :silent noh<CR>
nmap <C-E> :b#<CR>
nmap <C-P> :NERDTreeToggle<CR>
nmap <leader>p :NERDTreeFind<CR>
nmap <leader>/ :call NERDComment(0, "invert")<cr>
vmap <leader>/ :call NERDComment(0, "invert")<cr>
nmap <leader>t :TlistToggle<CR>
nmap <leader>e :e **/
nmap <Leader>b :MiniBufExplorer<cr>
nmap <Leader>sh :ConqueSplit bash<cr>
nmap <Leader>r :ConqueSplit 
" map ,y to show the yankring
nmap <leader>y :YRShow<cr>
imap <silent> <Down> <C-o>gj
imap <silent> <Up> <C-o>gk
nmap <silent> <Down> gj
nmap <silent> <Up> gk
cmap w!! %!sudo tee > /dev/null %
inoremap jj <Esc>
nnoremap JJJJ <Nop>

Any ideas would be appreciated. I tried flipping the delete key to send ^H or ^?, to no difference.

任何想法,将不胜感激。我试着翻转删除键来发送 ^H 或 ^?,没有区别。

回答by jamessan

Most likely, the "problem" you're seeing is that you can't delete anything that was not typed during your current insert mode session. This is due to the default setting for the 'backspace'option. Adding set backspace=indent,eol,startto your ~/.vimrcis the behavior that you probably want.

您所看到的“问题”很可能是您无法删除在当前插入模式会话期间未键入的任何内容。这是由于'backspace'选项的默认设置。添加set backspace=indent,eol,start到您的~/.vimrc是您可能想要的行为。

回答by Johan

This is the only explicit backspace mapping I have in my config. I do not know if it will help for your problem, but it might be worth a try?

这是我的配置中唯一的显式退格映射。我不知道它是否对您的问题有帮助,但可能值得一试?

" allow backspacing over everything in insert mode
set backspace=indent,eol,start