I cannot enter command mode by typing :.

What's more , whatever key I press, Vim will enter insert mode and type the word I've just typed. i.e. I type j, and the cursor doesn't move downwards but Vim enters insert mode and types the letter j on the screen, which is very weird.

I reinstalled Vim and it made no difference

Now as I cannot enter command mode, I cannot type :wq to save any change to vimrc file.

If the is problem caused by the wrong setting in vimrc, I have no idea about how to fix it. If not, what's the cause of the issue?


set nocompatible
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'tmhedberg/SimpylFold'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/syntastic'
Plugin 'nvie/vim-flake8'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
"color scheme
Plugin 'altercation/vim-colors-solarized'
" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
"let nerdtree ignore .pyc file
let NERDTreeIgnore=['\.pyc$', '\~$'] 
" change mapleader to ,
:let mapleader = "\<Space>"

" Enable folding
set foldmethod=indent
set foldlevel=99

" watch the text content in the folding block
let g:SimpylFold_docstring_preview=1

" set python file indent type
au BufNewFile,BufRead *.py
\ set tabstop=4
\ set softtabstop=4
\ set shiftwidth=4
\ set textwidth=79
\ set expandtab
\ set autoindent
\ set fileformat=unix

""""for the fullstack developer
au BufNewFile,BufRead *.js, *.html, *.css
\ set tabstop=2
\ set softtabstop=2
\ set shiftwidth=2

" make the additional whitespace show as the red
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/

"set encoding method 
set encoding=utf-8

"make the code more beautiful
let python_highlight_all=1
syntax on

"let vim visit the system clipboard
set clipboard=unnamed

"for the direction button goes wrong
set term=builtin_ansi
let g:spf13_no_omni_complete=1
inoremap <ESC>oA <ESC>ki
inoremap <ESC>oB <ESC>ji
inoremap <ESC>oC <ESC>li
inoremap <ESC>oD <ESC>hi

"map the G
nnoremap <CR> G

"go to the beginning of the file 
nnoremap <BS> gg

"delete the whole line and enter insert mode
:nnoremap <leader>d ddO

"fast edit and source the vimrc file
:nnoremap <leader>ev :vsplit $MYVIMRC<cr>
:nnoremap <leader>sv :source $MYVIMRC<CR>

"surround the string with "
:nnoremap <leader>' viw<esc>a"<esc>bi"<esc>lel 

"open NERDTree quickly
:nnoremap <leader>n :NERDTree<cr>

"fold the block
:nnoremap <space> za

" short cut to navigate the split window
:nnoremap <C-J> <C-W><C-J>
:nnoremap <C-H> <C-W><C-H>
:nnoremap <C-L> <C-W><C-L>
:nnoremap <C-K> <C-W><C-K>

"copy paste from system + register
:noremap <leader>y "+y
:noremap <leader>p "+p

"zoom in/zoom out window size
:nnoremap <leader>- <C-W>-

"use F9 to run the python file in vim 
nnoremap <buffer> <leader>r :exec '!python' shellescape(@%, 1)<cr>

"go to the definition by ycm
let g:ycm_autoclose_preview_window_after_completion=1
map <leader>g  :YcmCompleter GoToDefinitionElseDeclaration<CR>

"press multiple v select from a character a word to a sentence a block
vmap v <Plug>(expand_region_expand)

"come back to the last selection
vmap <C-v> <Plug>(expand_region_shrink)

"change esc to jk 
:noremap jk <esc>

"disable the esc button 
:inoremap <esc> <nop>

"set <leader>c to take comment
"for .js file
"for .py file 
:autocmd FileType javascript nnoremap <buffer><leader>c I//<esc>
:autocmd FileType python nnoremap <buffer> <leader>c I#<esc>

" change the color of ycm preview window
highlight Pmenu ctermfg=2 ctermbg=3 guifg=#ffffff guibg=#6495ED

"no swap file
set noswapfile

" colorscheme 
set t_Co=256
if has('gui_running')
  set background=dark
  colorscheme solarized
  colorscheme zenburn

"let the screen clear when quitting

"modify the window
set modifiable

"clear the window and quit / save quit
:set t_te=^[[H^[2J 

If it's a problem with my .vimrc, how can I edit the file and save the edit in these circumstances?

  • Can we see contents of .vimrc? – George Udosen Nov 17 '17 at 14:00
  • Are you hitting ESC before :? – steeldriver Nov 17 '17 at 14:10
  • @ steeldriver what means hitting esc before : ... if it means I press` :` just after I hit ESC, no of course not – LFBuildAMountain Nov 17 '17 at 14:14
  • 2
    @LFBuildAMountain - You've got the of course not wrong. Just to be clear: hitting ESC followed by : leaves you in insert mode? – Lieven Keersmaekers Nov 17 '17 at 14:29
  • 1
    @Zanna hit : normally can cause Vim to enter command mode , precisely when I immediately open Vim and I press : , Vim can enter the command line , but if I press i and enter the insert mode once. after I press ESC to quit the insert mode ,every next time , I press whatever key like` j` ,which should move the cursor downwards , y ,which should copy, these key will not take effect but enter the insert mode again from normal mode and type the letter j ,k on the screen – LFBuildAMountain Nov 17 '17 at 14:49

You're stuck in insert mode because the ESC key is disabled. Take the following out of your .vimrc:

"disable the esc button 
:inoremap <esc> <nop>
| improve this answer | |
  • Or use the mapping you've setup for ESC: :noremap jk <esc> – Lieven Keersmaekers Nov 17 '17 at 17:42

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.