Created
May 5, 2011 22:52
-
-
Save joelklabo/958143 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Completion menu: completes based on text of current file, as well as other | |
" open buffers/windows. Use <Tab> to open the menu (or pick another key, see | |
" the last line), as well as to cycle between the different options. Use | |
" <Enter> or <Space> to use use option. | |
set complete=.,w,b | |
set completeopt=longest,menu,menuone,preview | |
function! AutoCompleteOnKey(key) | |
if pumvisible() " menu open, loop through choices | |
return "\<Down>" | |
else " menu not open, open conditionally | |
if strpart(getline('.'), 0, col('.') - 1) =~ '^\s*$' | |
return a:key | |
else | |
return "\<C-N>\<C-R>=pumvisible() ? \"\\<Down>\" : \"\"\<CR>" | |
end | |
end | |
endfunction | |
inoremap <silent> <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
inoremap <silent> <expr> <Space> pumvisible() ? "\<C-y> " : "\<Space>" | |
inoremap <silent> <expr> <Tab> AutoCompleteOnKey("\<Tab>") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment