3

I'm trying to remap my Backspace key to do nothing in insert mode (want to start using more x and other different ways that are better for deletion in vim)

I added in my .vimrc this line:

inoremap <BS> <Nop>

But after restarting my vim the backspace still deletes a character.

What am I doing wrong?

This is part of my .vimrc:

set nocompatible
execute pathogen#infect()
syntax on
filetype plugin indent on
set laststatus=2
set background=dark
set number
set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab
set autochdir

set noswapfile
set backspace=indent,eol,start
set incsearch
set ignorecase
set fileencoding=utf-8
set encoding=utf-8
set gdefault
set smartcase
set scrolloff=5
let mapleader=","
map <C-n> :NERDTreeToggle<CR>

let g:ag_working_path_mode="ar"

let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'

let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'

 set wildignore+=*/tmp/*,*.so,*.swp,*.zip
let g:ctrlp_user_command = 'find %s -type f'

set hidden
nmap <leader>T :enew<cr>
nmap <leader>l :bnext<cr>
nmap <leader>h :bprev<cr>
nmap <leader>bq :bp <BAR> bd #<CR>
nmap <leader>bl :ls<CR>

nnoremap <leader>w :w<cr>
nnoremap <leader>q :q<cr>

noremap > >><cr>
noremap < <<<cr>

let g:ctrlp_custom_ignore = {
            \ 'dir':  '\v[\/]\.(git|hg|svn)$|/node_modules/',
            \ 'file': '\v\.(exe|so|dll)$',
            \ 'link': 'some_bad_symbolic_links',
            \ }
let g:ctrlp_dotfiles = 0
j
"autocmd BufWritePre * :normal gg=G
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
let g:UltiSnipsNoPythoWarning = 1

" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

" C tags
nmap <F8> :TagbarToggle<CR>
nnoremap <Leader>. :CtrlPTag<CR>
inoremap <leader>; <C-o>A;
nnoremap <leader>; A;

set diffopt+=vertical
inoremap <BS> <Nop>
"inoremap <Del> <Nop>
  • 1
    I used your vimrc but removed the pathogen#infect() and the mapping works correctly. So I suspect one of your plugin to cause the problem. Can you try to comment the execution of pathogen and see if the problem still occurs? – statox Apr 14 '16 at 12:23
  • Yes. You are right. That is one of the plugins. – Shikloshi Apr 14 '16 at 12:29
  • 1
    Before posting on this site I strongly recommend that you read (and apply) How do I debug my vimrc it will help you spot a vast majority of your problems. – statox Apr 14 '16 at 12:35
  • @statox Yes, I was not aware of this. I will do it now. – Shikloshi Apr 14 '16 at 12:48
  • 1
    Great! In the other hand don't hesitate to ask your questions when you already have done some debugging, the community of this site is generally pretty good to give fast and good answers :-) – statox Apr 14 '16 at 12:57
2

I could reproduce your issue by starting Vim without nocompatible set.

vim -u NONE -U NONE

It seems that the inoremap is not in Vi, so it won't do the map if you don't add the nocompatible option.

e.g. it works with:

vim -u NONE -U NONE -N

Also, as a general rule, you may want to start your vimrc with

set nocompatible

Note: next time have a look at How do I debug my vimrc file?

  • Sorry that is my bad, I use <BS>. Editing question now – Shikloshi Apr 14 '16 at 12:06
  • OK, but I got it working here, strange... – nobe4 Apr 14 '16 at 12:08
  • Yep, I know. Suppose to be really simple. Not sure why this is not working for me. – Shikloshi Apr 14 '16 at 12:08
  • have you tried without any config in you vimrc file ? – nobe4 Apr 14 '16 at 12:09
  • can you try with and without the compatible option set? It doesn't work without also. – nobe4 Apr 14 '16 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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