1

Preliminary Info:

  • Issue is in terminal Vim, not gVim
  • I used CMDER (based on conemu) as my terminal emulator
  • I am on Windows 10

Detailed Description:

When I'm in Insert mode, I can type text as normal, but backspace does nothing. While in normal mode, the backspace key deletes text. This is exactly opposite the behavior I had just earlier today. I have read numerous other posts online describing Vim's unorthodox backspace behavior, but the suggested config settings (namely bs=2 or bs=indent,eol,start) had done nothing.

More unusual is that gVim behaves "normally" that is: Backspace move the cursor to the left in normal mode, and deletes text in insert mode.

What I would like is for backspace to delete text in insert mode (just like most other programs) and to be navigation/disabled in normal mode. How can I regain this behavior?

Below is a copy of my _vimrc: (I would put this on github but my git is messed up at the moment and I've yet to fix it.) Additionally there was a function that was inside of the _vimrc by default. I have no idea what it does but omitted it to save space. If you want to see if I can post it in a reply.

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
3
  • Did you try without your config, $ vim -Nu NONE?
    – romainl
    Commented Apr 26, 2018 at 8:16
  • @romainl Could you clarify what actually needs to be put into the command? Vim is giving me invalid command errors.
    – Jordan S.
    Commented Apr 26, 2018 at 12:26
  • Nothing. Just use that command to start Vim without your config to see if the problem is a Vim problem or a config problem.
    – romainl
    Commented Apr 26, 2018 at 13:05

1 Answer 1

5

Most likely, your insert-mode backspace is mapped to do nothing (i.e. <nop>). Verify this by typing :verbose imap <bs>. This will show if backspace key is mapped and where the map was set.

What I would like is for backspace to delete text in insert mode (just like most other programs) and to be navigation/disabled in normal mode. How can I regain this behavior?

You can do:

iunmap <bs>
nnoremap <bs> <nop>

The first line unmaps <bs> in insert mode, thus <bs> will recover its default functionality. The second line maps <bs> in normal mode to do nothing.

5
  • Thanks for the reply! The command :verbose imap <bs> yields: 'E31: No such mapping' and when I attempt iunmap <bs> it gives me the same answer. Any suggestions?
    – Jordan S.
    Commented Apr 26, 2018 at 12:24
  • Follow the advise in the comment above and open Vim with the command vim -Nu NONE from your terminal. Does the problem persist? Commented Apr 26, 2018 at 15:07
  • When I start vim without a config it behaves normally, backspace works as long as you stay in edit mode (e.g. you can't edit old text) but that's just a normal feature of vim. So I suppose the question is, what in my config could be causing it? Would disabling each setting in order be a good test?
    – Jordan S.
    Commented Apr 26, 2018 at 15:55
  • This may work: Create a log file with high verbosity level. This file will contain information like loaded plugins, set options and more (see :help verbose). To create the log file enter the command vi -V20vimlog -c q in your terminal. This should create a log file called vimlog in your current directory. Open the file in Vim and look for anything that could be causing your problem. For example search for keywords like <bs> or backspace. Commented Apr 26, 2018 at 16:39
  • Ok, I created the log file and noticed that the first two lines of my config call other config files to be loaded first before my own. So I commented out those lines and now backspace functions as a rightward delete in edit mode. Which is an improvement! Interestingly it also broke syntax highlighting but re-enabling vimrc_example fixed that issue. I'll dig through that file and see what it's doing. Frankly, I think I'll just use a rightward delete while everything is working for fear of breaking something again. Thank you so much for the help! I never would have found this elsewhere.
    – Jordan S.
    Commented Apr 26, 2018 at 17:40

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