• 我的Vim配置


    带括号补齐

     1 syntax on
     2 filetype plugin on
     3 let filetype_m='objc'
     4 set nocompatible
     5 set encoding=utf-8
     6 set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
     7 set history=400
     8 set autoread
     9 set nu
    10 set ai
    11 set cindent
    12 set cmdheight=2
    13 set backspace=eol,start,indent
    14 set ignorecase smartcase
    15 set incsearch
    16 set magic
    17 set hlsearch
    18 set laststatus=2
    19 set tabstop=4
    20 set shiftwidth=4
    21 
    22 "Format the statusline
    23 set statusline=%F%m%r%h%w/[FORMAT=%{&ff}]/[TYPE=%Y]/[ASCII=%03.3b]/[HEX=/%02.2B]/[POS=%04l,%04v][%p%%]/[LEN=%L]
    24 
    25 "Map auto complete of (, ", ', [, {
    26 :inoremap <S-ENTER> <c-r>=SkipPair()<CR>
    27 :inoremap <S-SPACE> <ESC>la
    28 :inoremap <C-ENTER> <ESC>A;<CR>
    29 :inoremap ( ()<ESC>i
    30 :inoremap ) <c-r>=ClosePair(')')<CR>
    31 :inoremap { <c-r>=ClsoeBrace()<CR>
    32 :inoremap } <c-r>=ClosePair('}')<CR>
    33 :inoremap [ []<ESC>i
    34 :inoremap ] <c-r>=ClosePair(']')<CR>
    35 ":inoremap < <><ESC>i
    36 ":inoremap > <c-r>=ClosePair('>')<CR>
    37 :inoremap ;; <ESC>A;<CR>
    38 
    39 function ClosePair(char)
    40     if getline('.')[col('.') - 1] == a:char
    41         return "\<Right>"
    42     else
    43         return a:char
    44     endif
    45 endf
    46 function Semicolon()
    47 "echo getline('.')[col('.')]
    48     if getline('.')[col('.')] == ')'
    49         return "<ESC>A;"
    50     elseif getline('.')[col('.')] == '}'
    51         return "\<ESC>A;"
    52     elseif getline('.')[col('.')] == ']'
    53         return "\<ESC>A;"
    54     else
    55         return ";"
    56     endif
    57 endf
    58 function SkipPair()
    59     if getline('.')[col('.') - 1] == ')'
    60         return "\<ESC>o"
    61     else
    62         normal j
    63         let curline = line('.')
    64         let nxtline = curline
    65         while curline == nxtline
    66             if getline('.')[col('.') - 1] == '}'
    67                 normal j
    68                 let nxtline = nxtline + 1
    69                 let curline = line('.')
    70                 continue
    71             else
    72                 return "\<ESC>i"
    73             endif
    74         endwhile
    75         return "\<ESC>o"
    76     endif
    77 endf
    78 function ClsoeBrace()
    79     if getline('.')[col('.') - 2] == '='
    80         return "{}\<ESC>i"
    81     elseif getline('.')[col('.') - 3] == '='
    82         return "{}\<ESC>i"
    83     elseif getline('.')[col('.') - 1] == '{'
    84         return "{}\<ESC>i"
    85     elseif getline('.')[col('.') - 2] == '{'
    86         return "{}\<ESC>i"
    87     elseif getline('.')[col('.') - 2] == ','
    88         return "{}\<ESC>i"
    89     elseif getline('.')[col('.') - 3] == ','
    90         return "{}\<ESC>i"
    91     else
    92         return "{\<ENTER>}\<ESC>O"
    93     endif
    94 endf
  • 相关阅读:
    PopupWindow设置动画效果
    android判断是否含有某权限
    每日一更提醒
    利用Pattern和Mather来禁止特殊字符的输入
    Android毛玻璃处理代码(Blur)
    how to render html tag
    数组
    复杂度分析
    书写markdown的利器
    cannot insert multiple commands into a prepared statement问题原因及解决办法
  • 原文地址:https://www.cnblogs.com/jojodru/p/2487519.html
Copyright © 2020-2023  润新知