2个vim问题

Vim、Emacs配置和使用
头像
fanhe
帖子: 2357
注册时间: 2007-03-24 23:45

Re: 2个vim问题

#31

帖子 fanhe » 2012-09-14 17:08

eexpress 写了:补全,vim自带的够了。其他的真不重要。
lilydjwg, 27楼的,想想。
有什么好想的,你首先应该

代码: 全选

:h ins-completion
就你上面那个问题,直接

代码: 全选

:set opt-=i
这是我自己用的

代码: 全选

inoremap <silent> <Tab> <C-r>=<SID>i_Tab_plus()<CR>
inoremap <silent> <expr> <S-Tab> pumvisible()?"\<C-p>":"\<C-d>"

function! s:i_Tab_plus() "{{{2
    let preChar = getline('.')[col('.') - 2]
    if pumvisible()
        return "\<C-n>"
    elseif preChar == '' || preChar =~ '\s'
        return "\<Tab>"
    elseif (getline('.')[col('.') - 3] == '-' && preChar == '>') || preChar == '.'
        return "\<C-x>\<C-o>"
    elseif &ft ==# 'c' || &ft ==# 'cpp'
        return "\<C-n>"
    else
        return "\<C-x>\<C-n>"
    endif
endf
回复