Created
January 23, 2013 17:09
-
-
Save spangenberg/4610152 to your computer and use it in GitHub Desktop.
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
| let NERDTreeIgnore=['\.pyc$', '\.pyo$', '\.rbc$', '\.rbo$', '\.class$', '\.o$', '\~$'] | |
| augroup AuNERDTreeCmd | |
| autocmd AuNERDTreeCmd VimEnter * call s:CdIfDirectory(expand("<amatch>")) | |
| autocmd AuNERDTreeCmd FocusGained * call s:UpdateNERDTree() | |
| " If the parameter is a directory, cd into it | |
| function s:CdIfDirectory(directory) | |
| let explicitDirectory = isdirectory(a:directory) | |
| let directory = explicitDirectory || empty(a:directory) | |
| if explicitDirectory | |
| exe "cd " . fnameescape(a:directory) | |
| endif | |
| " Allows reading from stdin | |
| " ex: git diff | mvim -R - | |
| if strlen(a:directory) == 0 | |
| return | |
| endif | |
| if directory | |
| NERDTree | |
| wincmd p | |
| bd | |
| endif | |
| if explicitDirectory | |
| wincmd p | |
| endif | |
| endfunction | |
| " NERDTree utility function | |
| function s:UpdateNERDTree(...) | |
| let stay = 0 | |
| if(exists("a:1")) | |
| let stay = a:1 | |
| end | |
| if exists("t:NERDTreeBufName") | |
| let nr = bufwinnr(t:NERDTreeBufName) | |
| if nr != -1 | |
| exe nr . "wincmd w" | |
| exe substitute(mapcheck("R"), "<CR>", "", "") | |
| if !stay | |
| wincmd p | |
| end | |
| endif | |
| endif | |
| endfunction | |
| " behavior | |
| let g:NERDTreeWinPos = 'right' | |
| set cpoptions+=$ |
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
| let NERDTreeHijackNetrw = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment