ubuntu - VIM键盘映射使用了终端的热键
巴扎黑
巴扎黑 2017-04-21 10:55:52
0
1
604

自己编写的键盘映射失灵,而且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的配置文件我没有做任何更改
求问这个问题要怎么设置才能解决

巴扎黑
巴扎黑

全部回覆(1)
刘奇

自己寫的鍵盤映射失靈,而vim正在使用bash的熱鍵,
導致我的vim現在的操作是這樣的
插入模式下
ctrl-w 刪除遊標前的一個單字
ctrl-L 打出了^L
CTRL-J 換行

這只是巧合,實際vim不是使用bash的熱鍵,而是使用本身預設的熱鍵而已,參考幫助文檔:h i_CTRL-w。这里正确的做法是使用noremap來覆蓋預設熱鍵。

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

其它組合鍵類似。 ctrl-w預設是作為window導航的重要熱鍵,個人是不建議覆蓋的。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!