Last active
December 11, 2015 23:08
-
-
Save SamWhited/4673991 to your computer and use it in GitHub Desktop.
Parse a .gitignore file in vim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Load a .gitignore file from the current directory | |
" and parse it for use in Vim | |
let gitignore = '.gitignore' | |
if filereadable(gitignore) | |
let igstring = '' | |
for oline in readfile(gitignore) | |
let line = substitute(oline, '\s|\n|\r', '', "g") | |
if line =~ '^#' | con | endif | |
if line == '' | con | endif | |
if line =~ '^!' | con | endif | |
if line =~ '/$' | let igstring .= "," . line . "*" | con | endif | |
let igstring .= "," . line | |
endfor | |
let execstring = "set wildignore+=".substitute(igstring, '^,', '', "g") | |
execute execstring | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment