-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathformat.vim
42 lines (39 loc) · 1.31 KB
/
format.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
" 删除空行
function RemoveTrailingWhitespace()
if &ft != "diff"
let b:curcol = col(".")
let b:curline = line(".")
%s/\s\+$//e
" $put _
%s/\(\s*\n\)\+\%$/\r/ " 删除结尾空格
%s/\n\{3,}/\r\r/e " 删除多余空行
%s/\n\+\%$//ge " 删除文件尾部多余换行
call cursor(b:curline, b:curcol)
endif
endfunction
"function JavaScriptSyntax()
"
" let bin = get(g:, 'node_bin', '/usr/bin/env node')
" let cmd = bin . ' ' . shellescape(expand('%:p'))
" let msg = systemlist(cmd)
"
" if len(msg) && msg[4] =~ 'SyntaxError'
"
" let ln = matchstr(msg[0], '[0-9]\+\>')
" if strlen(ln)
" exe ':' . ln
" endif
"
" echo ' '
" echo msg[0]
" echo ' '
" echo msg[4]
" echo ' '
" endif
"endfunction
" UNIX 换行
au FileType php,sh,fstab,zsh,json,typescript,javascript,css,less,sass,scss,text,html,dosini,vim,gitconfig,conf,nginx au BufWritePre * :silent! undojoin | silent! call RemoveTrailingWhitespace()
au FileType php,sh,fstab,zsh,json,typescript,javascript,css,less,sass,scss,text,html,dosini,vim,gitconfig,conf,nginx,mkd silent! set fileformat=unix
au FileType go au BufWritePre * :silent! undojoin | silent! call RemoveTrailingWhitespace() | silent! Fmt
" au FileType javascript au BufWritePost * :call JavaScriptSyntax()
au BufWritePre ~/conf/filelist,~/conf/apt/list-aptget,~/conf/apt/list-desktop :sort