Created
November 23, 2012 17:34
-
-
Save pschyska/4136592 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
" Highlight currently open file in nerdtree | |
" see http://superuser.com/a/474298/175466 | |
" see http://superuser.com/a/509721/175466 | |
" returns true iff is NERDTree open/active | |
function! rc:isNTOpen() | |
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1) | |
endfunction | |
" returns true iff focused window is NERDTree window | |
function! rc:isNTFocused() | |
return -1 != match(expand('%'), 'NERD_Tree') | |
endfunction | |
" returns true iff focused window contains a file in current pwd | |
function! rc:isInsideCwd() | |
return -1 != stridx(expand('%:p'), getcwd()) | |
endfunction | |
" calls NERDTreeFind iff NERDTree is active, current window contains a modifiable file, and we're not in vimdiff | |
function! rc:syncTree() | |
if &modifiable && rc:isNTOpen() && !rc:isNTFocused() && strlen(expand('%')) > 0 && !&diff && rc:isInsideCwd() | |
NERDTreeFind | |
wincmd p | |
endif | |
endfunction | |
autocmd BufEnter * call rc:syncTree() |
which directory do you put this file in?
doesnt work when i put ut in
/Users//.local/share/nvim
@Amarlanda This snippet can go into your normal vim config. For neovim, this is ~/.config/nvim/init.vim by default. Just paste the file contents at the end of init.vim.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exactly what i am looking for, thank you