Home  >  Q&A  >  body text

ubuntu - VIM键盘映射使用了终端的热键

自己编写的键盘映射失灵,而且vim正在使用bash的热键,
导致我的vim现在的操作是这样的
插入模式下
ctrl-w 删除光标前的一个单词
ctrl-L 打出了^L
CTRL-J 换行

怎么才能正常配置使用键盘映射
我的vim有两个插件,youcompleteme,vundle
我的系统是ubuntu gnome

我自己的vimrc是这样

"基本设置
set nu
set tabstop=4
set bg=dark
set expandtab
set cursorline
set softtabstop=4
set hls
set shiftwidth=4
set fdm=syntax
set foldlevelstart=99
set autoindent
au filetype c,cpp set cindent
"键盘映射
map <S-Right> <Esc>:tabn<CR>
imap <S-Right> <Esc>:tabn<CR>i
map <S-Left>  <ESC>:tabp<CR>
imap <S-Left>  <ESC>:tabp<CR>i
map <C-o>     <Esc>:tabnew 
imap <C-o>     <Esc>:tabnew 
map <F5>      <Esc>:w<CR>:!g++ % -o %<<CR>
imap <F5>      <Esc>:w<CR>:!g++ % -o %<<CR>
map <C-F5>    <Esc>:w<CR>:!g++ % -o %< && ./%<<CR>
imap <C-F5>    <Esc>:w<CR>:!g++ % -o %< && ./%<<CR>
map <C-s>   <Esc>:w<CR>
imap <C-s>  <Esc>:w<CR>i
map <C-w> <Esc>:wq<CR>
imap <C-w> <Esc>:wq<CR>
"颜色
set t_Co=256
color darkburn
"vundle设置
set nocompatible
set backspace=2
filetype off                  " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required! 
Bundle 'gmarik/vundle'
" My bundles here:
" original repos on GitHub
Bundle 'Valloric/YouCompleteMe'
"Bundle 'tpope/vim-fugitive'
"Bundle 'Lokaltog/vim-easymotion'
"Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
"Bundle 'tpope/vim-rails.git'
" vim-scripts repos
"Bundle 'L9'
"Bundle 'FuzzyFinder'
" non-GitHub repos
"Bundle 'git://git.wincent.com/command-t.git'
" Git repos on your local machine (i.e. when working on your own plugin)
"Bundle 'file:///Users/gmarik/path/to/plugin'
" ...
filetype plugin indent on     " required!
"YCM设置
set completeopt=longest,menu "关掉补全的预览
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py' "默认配置
let g:ycm_confirm_extra_conf = 0 "不需手动确认

bash的配置文件我没有做任何更改
求问这个问题要怎么设置才能解决

巴扎黑巴扎黑2715 days ago610

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-04-21 10:57:52

    The keyboard mapping I wrote failed, and vim is using bash’s hotkeys,
    The current operation of my vim is like this
    In insert mode
    ctrl-w deletes the word before the cursor
    ctrl-L typed ^L
    CTRL-J line feed

    This is just a coincidence. In fact, vim does not use bash hotkeys, but uses its own default hotkeys. Please refer to the help document:h i_CTRL-w。这里正确的做法是使用noremap to override the default hotkeys.

    noremap <C-w> <Esc>:wq<CR>
    inoremap <C-w> <Esc>:wq<CR>
    

    Other key combinations are similar. ctrl-w defaults to an important hotkey for window navigation, and I personally do not recommend overriding it.

    reply
    0
  • Cancelreply