迷惘的码农。
分类:
2010-10-27 10:43:38
" 选中代码片段后,按键”\=>“ function! AlignPHPMap() range
let sep = '=>'
let firstline = a:firstline let lastline = a:lastline let lines = {} for lineno in range(firstline, lastline) let lines[lineno] = match(getline(lineno), '\s*' . sep) endfor let maxLen = max(lines) + 1 for lineno in range(firstline, lastline) if lines[lineno] != -1 let spaces = repeat(' ', maxLen - lines[lineno]) call setline(lineno, substitute(getline(lineno), '\s*' . sep . '\s*', spaces . sep . ' ', '')) endif endfor endfunction noremap |