自用的两个vim函数Tab/Space互转和Tab键补全

左手 posted @ 2013年6月09日 20:56 in Vim with tags vim缩进转换 vim设置tab键补全 , 2799 阅读

1. Tab和Space转换函数,expandtab和rettab的组合运用。命令:ToTab,:ToSpace分别转换当前文件到tab缩进和space缩进。

" --------------------------------------------------
" [空格与制表切换] {{{
" --------------------------------------------------
fu! ToggleTab(t)
    if a:t == 'tab'
        setl noet
        ret!
    elsei a:t == 'space'
        setl et
        ret
    en
endf
com! -nargs=0 ToSpace call ToggleTab('space')
com! -nargs=0 ToTab call ToggleTab('tab')
" }}}

2. Tab键补全,这个是以前网上的配置里面摘出来的。用惯了Tab键补全,C-p、C-n实在不习惯。函数做了简单的判断,在字母后面为补全,其它地方为Tab键。后面了加一个Shift+Tab的强制Tab键映射,在任何情况下都能键入tab。

" --------------------------------------------------
" [自动完成函数] {{{
" --------------------------------------------------
" 自动完成
fu! InsertTabWrapper()
    let col=col('.')-1
    return (!col || getline('.')[col-1] !~ '\k') ? "\<TAB>" : "\<C-P>"
endf
" 映射键
ino <TAB> <C-R>=InsertTabWrapper()<CR>
" 强制TAB键
ino <S-TAB> <C-R>="\<TAB>"<CR>
" }}}
Avatar_small
Kerala 4th Class Sy 说:
2023年9月12日 14:28

SCERT Kerala Elementary Syllabus 2024 is Designed in Accordance with the NCERT Based Guidelines and helps Students to get an Overview of the Malayalam, English Medium All Subject, Kerala keeps a 4th Class Exam Pattern with the aim to Provide a Quality Education for All Students, On the basis of the Current Educational Demands.Students Should Download the Respective Stream wise Kerala Class Kerala 4th Class Syllabus 2024 Exam Syllabus 2024 Subjects of Malayalam, English, Mathematics, EVS Pdf Format Provide Check the same From our page here,So Students need to Start Their Preparation by first Downloading the Stream wise Kerala Curriculum Syllabus 2024 Latest Edition.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter