Vim tab auto-complete

https://news.ycombinator.com/item?id=137301
by marrone • 18 years ago
4 1 18 years ago

Hey, for the vimmers out there, this is such a great customization that I thought I'd pass it along for anyone who is interested. Add the following to your vimrc and you can use tab to auto-complete words while still preserving it as a tab insert where most appropriate (whenever your cursor is not over a word).

Anyone care to share their favorite vim tips?

function InsertTabWrapper()

    let col = col('.') - 1 

    if !col || getline('.')[col - 1] !~ '\k'

        return "\<tab>"

    else

        return "\<c-p>"

    endif
endfunction

inoremap <tab> <c-r>=InsertTabWrapper()<CR>

Related Stories

Loading related stories...

Source preview

news.ycombinator.com