-
Notifications
You must be signed in to change notification settings - Fork 0
/
files.vim
33 lines (28 loc) · 1.03 KB
/
files.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
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
set path+=**
" Ignore compiled files
set wildignore=*.o,*~,*.pyc,*.class
set wildignore+=*/.git/*
set wildignore+=*/.svn/*
command! GitIgnore call <SID>SetWildIgnoreFromGitIgnore()
function! <SID>SetWildIgnoreFromGitIgnore()
let filename = '.gitignore'
if filereadable(filename)
let igstring = ''
for oline in readfile(filename)
let line = substitute(oline, '\s|\n|\r', '', "g")
if line =~ '^#' | con | endif
if line == '' | con | endif
if line =~ '^!' | con | endif
if line =~ '/\*$' | let igstring .= "," . getcwd() . '/' .line | con | endif
if line =~ '^/.*/$' | let igstring .= ',' . '*' . line . '*' | con | endif
if line =~ '/$' | let igstring .= ',' . getcwd() . '/' . line . '*' | con | endif
let igstring .= "," . substitute(line, ' ', '\\ ', "g")
endfor
let execstring = "set wildignore=".substitute(igstring, '^,', '', "g")
execute execstring
endif
endfunction