vim - set complete+=k[file] not working for whole line completion? -


i have ~/.bash_history contains lines such sudo apt-get install, aplay foo.wav, etc. thought convenient if use these lines completing whole lines while writing shell scripts.

:h compl-whole-line says:

ctrl-x ctrl-l
search backwards line starts same characters in current line before cursor. indent ignored. matching line inserted in front of cursor. ** 'complete' option used decide buffers searched match. both loaded , unloaded buffers used.**

note asterisks inserted. :h 'complete' says:

 k      k{dict} scan file {dict}.  several "k" flags can given,         patterns valid too.  example: >         :set cpt=k/usr/dict/*,k~/spanish 

so thought :set complete+=k~/.bash_history job. didn't.

start vim with

$ vim -u none -n 

then

:set complete+=k~/.bash_history :set complete? " complete=.,w,b,u,t,i,k~/.bash_history 

, enter insert mode (i), , when type

su<c-x><c-l> 

, vim says whole line completion (^l^n^p) pattern not found. completion working words, when type

su<c-p> 

sudo suggested.

what missing? how can use history whole line completion without :sp ~/.bash_history?

set complete+=k[file] has nothing line completion: whatever file give used source dictionary completion (<c-x><c-k>) , keyword completion (<c-n>/<c-p>).

:help i_ctrl-x_ctrl-l clear: line completion works lines found in loaded , unloaded buffers. since ~/.bash_history not loaded buffer, line completion never use source.

so yes, practical solution load file.

:sp ~/.bash_history not optimal, though, because a) takes room, both physically , in buffer list, , b) requires way many keystrokes.

the "too room" part of problem solved more suited command:

:badd ~/.bash_history 

the "too many keystrokes" part of problem solved autocommand runs command above each time edit shell script:

augroup shell     autocmd!     autocmd bufnewfile,bufread *.sh badd ~/.bash_history augroup end 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -