Vim: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Sven (Diskussion | Beiträge) (tab-completion mit vim) |
Sven (Diskussion | Beiträge) (→Tab-Completion: format fix) |
||
Zeile 1: | Zeile 1: | ||
=Tab-Completion= | =Tab-Completion= | ||
<pre> | |||
function InsertTabWrapper(direction) " automagically decide what to do with <tab> | function InsertTabWrapper(direction) " automagically decide what to do with <tab> | ||
let col = col('.') -1 " <s-tab> in insert mode | let col = col('.') -1 " <s-tab> in insert mode | ||
Zeile 17: | Zeile 17: | ||
inoremap <tab> <c-r>=InsertTabWrapper(1)<cr> | inoremap <tab> <c-r>=InsertTabWrapper(1)<cr> | ||
inoremap <s-tab> <c-r>=InsertTabWrapper(-1)<cr> | inoremap <s-tab> <c-r>=InsertTabWrapper(-1)<cr> | ||
</pre> |
Version vom 7. Februar 2006, 19:09 Uhr
Tab-Completion
function InsertTabWrapper(direction) " automagically decide what to do with <tab> let col = col('.') -1 " <s-tab> in insert mode if !col return "\<tab>" " insert Tab at the beginning of the line elseif a:direction < 0 return "\<c-p>" " insert Backward-Completion elseif getline('.')[col - 1] == '<space>' return "\<BS>\<TAB>" " replace <space><tab> with <tab> elseif getline('.')[col - 1] !~ '\k' return "\<tab>" " insert Tab if preceding character is not a keyword character else return "\<c-n>" " insert Forward-Completion endfunction inoremap <tab> <c-r>=InsertTabWrapper(1)<cr> inoremap <s-tab> <c-r>=InsertTabWrapper(-1)<cr>