Create a gist now

Instantly share code, notes, and snippets.

" Taken from https://github.com/carlhuda/janus/blob/master/janus/vim/tools/janus/after/plugin/nerdtree.vim
" Pins NERDTree to the left hand side
"
augroup AuNERDTreeCmd
autocmd AuNERDTreeCmd FocusGained * call s:UpdateNERDTree()
augroup END
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment