43

I just installed the 64-bit zipped version for Windows of gvim on my new machine at work, and I changed some settings to make it compatible with Visual Studio 2010.

Now the backspace key doesn't work for some reason.

Here's my .vimrc file:

set nowrap
set ruler
set encoding=utf-8
set fileencoding=utf-8
set ff=dos

It's only a minor annoyance (the delete key works), but I was just wondering if anybody knew.

4
  • Wild guess, have you earlier had source mswin.vim in your vimrc and now it's missing?
    – johnny
    Mar 24, 2011 at 14:03
  • @Johnny I do have that file (mswin.vim) in my C:\Program Files\vim72
    – leeand00
    Mar 24, 2011 at 14:36
  • I'm no vim expert but I have noticed that backspace works in a different way if source mswin.vim is missing from the vimrc file. Ctrl-C, Ctrl-V also will not copy/paste
    – johnny
    Mar 24, 2011 at 18:14
  • 1
    If you need to check it, I found this link helps: vim.wikia.com/wiki/Open_vimrc_file
    – johnny
    Mar 24, 2011 at 18:18

2 Answers 2

79

Does it entirely not work, or does it just not backspace past where you went into insert mode? There's an option backspace which controls this:

Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert
mode.  This is a list of items, separated by commas.  Each item allows
a way to backspace over something:
value       effect
indent      allow backspacing over autoindent
eol         allow backspacing over line breaks (join lines)
start       allow backspacing over the start of insert; CTRL-W and CTRL-U
            stop once at the start of insert.

owen_water's suggestion is the same as Carpetsmoker's comment, enabling all three of these. That's generally what people want, since it's a bit surprising to have Vim refuse to let you backspace text that's right there. So take your pick of the two equivalent choices - I'd go with the more verbose and clear one:

set backspace=2
set backspace=indent,eol,start

In some cases, bad terminals can mess with backspace and delete, but I doubt that's your problem in Windows. There is some ability to fix this; see :help fixdel.

4
  • In Cygwin on Windows7, I used the following .vimrc to fix the backspace issue. set nocompatible syntax on set nu set ts=2 set autoindent set bs=2 set bs=indent,eol,start fixdel
    – Jerry Tian
    Jul 30, 2011 at 9:15
  • 2
    @Jerry: nocompatible is set (rather, compatible is off) by default if you have a vimrc, syntax highlighting, line numbering, tabstops, and indentation are irrelevant, so your solution is exactly what I posted, plus some redundancy - backspace=2 and backspace=indent,eol,start are completely equivalent.
    – Cascabel
    Jul 30, 2011 at 19:22
  • 1
    You are right, @Jefromi I just copy my whole .vimrc to confirm that your answer also works in Cygwin too. Should only focus on the relevant part to make the answer clear.
    – Jerry Tian
    Aug 2, 2011 at 8:10
  • Using Windows 8.1 with the grapic version of Vim 7.4 the set backspace=indent,eol,start command allowed me to use backspace just like I do in Linux, thanks! Nov 16, 2015 at 9:48
13

never use vim in Windows, but I have meet the same problem before in open solaris.
Just try:

set backspace=2
1
  • 8
    I have: set backspace=indent,eol,start in my ~/.vimrc Mar 25, 2011 at 1:16

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.