autocomplpop.vimを入れてやったこと-vimプラグイン
AutoComplPop - Automatically opens popup menu for completions : vim online
autocomplpop.vim 2.6 をダウンロード。
~/.vim/plugin/に投げる。
補完候補の指定
autocomplpop.vim - vimグループを読み、補完候補はAutoComplPop_CompleteOptionで設定すれば良いことを知る。
autocomplpop.vim による自動補完が便利すぎる - cooldaemonの備忘録を参考に設定してみる。
autocmd Filetype * let g:AutoComplPop_CompleteOption='.,w,b,u,t,i' autocmd Filetype java let g:AutoComplPop_CompleteOption='.,w,b,u,t,i,k~/.vim/dict/j2se14.dict' autocmd Filetype c let g:AutoComplPop_CompleteOption='.,w,b,u,t,i,k~/.vim/dict/c.dict'
w,b,u,t,iとかはvimのcompleteオプションと同じだと思う。http://www15.ocn.ne.jp/~tusr/vim/options_help.html
辞書ファイルj2se14.dictはどこかからダウンロードしました。
ポップアップの色を変更したくなる
highlight Pmenu ctermbg=4 highlight PmenuSel ctermbg=1 highlight PMenuSbar ctermbg=4
コピペ。これでいい感じになった。
PmenuとかPmenuSelとかどこを指しているのか、勘でしか分かってない。
4とか1がどの色を指しているのかも調べてない。
ちなみに以下のような色の指定もできるみたいである。
autocomplpop.vimでリアルタイムにキーワード補完 - ナレッジエース
hi Pmenu guibg=#666666 hi PmenuSel guibg=#8cd0d3 guifg=#666666 hi PmenuSbar guibg=#333333
ホップアップを中止したり、再開したりできるようにしたい
そんなことできないかなぁ〜とtwitterで呟いていたところ、id:thincaさんに教えてもらう。
thinca on Twitter: "@rdera :AutoComplPopDisable ?"
thinca on Twitter: "@rdera autocomplpop.vimを一時的に無効にするコマンドです。 :AutoComplPopEnable で再び有効化されます。"
ということで。
inoremap ,s <ESC>:AutoComplPopDisable<CR>a inoremap ,q <ESC>:AutoComplPopEnable<CR>a nnoremap ,s :AutoComplPopDisable<CR> nnoremap ,q :AutoComplPopEnable<CR>
,sで無効に。
,qで有効にするようにした。
tabで補完候補を移動できないかなぁ〜
と思い始める。
C-pとかC-nで移動して、C-yで選択がデフォルトみたいだけど。
やはり、tabで移動したい。
コピペ。
autocomplpop.vimでリアルタイムにキーワード補完 - ナレッジエース
"<TAB>で補完 " {{{ Autocompletion using the TAB key " This function determines, wether we are on the start of the line text (then tab indents) or " if we want to try autocompletion function! InsertTabWrapper() let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k' return "\<TAB>" else if pumvisible() return "\<C-N>" else return "\<C-N>\<C-P>" end endif endfunction " Remap the tab key to select action with InsertTabWrapper inoremap <tab> <c-r>=InsertTabWrapper()<cr> " }}} Autocompletion using the TAB key
___________________________________________________________
2009/01/14追記
id:kuhukuhunさんに反応して頂く
inoremap <silent> <expr> ,t \ (exists('#AutoComplPopGlobalAutoCommand#InsertEnter')) ? "\<C-o>:AutoComplPopDisable\<CR>" : "\<C-o>:AutoComplPopEnable\<CR>"
普通にこっちの方が良いですね。
このような方法があったのですか。
でも、浅学で分からない。
調べてみます。
追記します。