74

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

When I type backspace on 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.

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

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

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.

2 Answers 2

191

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,start to your ~/.vimrc is the behavior that you probably want.

4
  • 1
    Aha, that was it. Magic. Thank you!
    – cflewis
    Aug 21, 2010 at 1:22
  • 17
    Fine sir, thank you! I hope you have long and prosperous life. Sep 25, 2013 at 14:44
  • 11
    Why in the world is this the default and why haven't I run into this problem before? I've used VIM a lot and I've used VIM on Mac before... I'm only just now experiencing this. Jul 4, 2017 at 18:22
  • 1
    Same - could have sworn that this stopped working for me recently, thanks!
    – Mark Brown
    Jun 15, 2022 at 12:58
19

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
2
  • 3
    You got it, this worked great, but I have jamessan the answer points because he knew why. Thanks for your help!
    – cflewis
    Aug 21, 2010 at 1:22
  • Anyone know how to do this in lua? Jul 21, 2022 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.