Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Merge branch 'focus_toggle'
Browse files Browse the repository at this point in the history
  • Loading branch information
jistr committed May 13, 2014
2 parents 661202d + 356c599 commit d446627
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -66,6 +66,9 @@ Vim-nerdtree-tabs provides these commands:
* `:NERDTreeSteppedClose` unfocuses the NERDTree, or closes/hides it if it was
not focused.

* `:NERDTreeFocusToggle` focus the NERDTree or create it if focus is
on a file, unfocus NERDTree if focus is on NERDTree

There are also plug-mappings available with the same functionality:

* `<plug>NERDTreeTabsOpen`
Expand Down
19 changes: 19 additions & 0 deletions nerdtree_plugin/vim-nerdtree-tabs.vim
Expand Up @@ -70,6 +70,7 @@ noremap <silent> <script> <Plug>NERDTreeMirrorOpen :call <SID>NERDTreeMirrorOr
noremap <silent> <script> <Plug>NERDTreeMirrorToggle :call <SID>NERDTreeMirrorToggle()
noremap <silent> <script> <Plug>NERDTreeSteppedOpen :call <SID>NERDTreeSteppedOpen()
noremap <silent> <script> <Plug>NERDTreeSteppedClose :call <SID>NERDTreeSteppedClose()
noremap <silent> <script> <Plug>NERDTreeFocusToggle :call <SID>NERDTreeFocusToggle()
"
" }}}
" === plugin commands === {{{
Expand All @@ -81,6 +82,7 @@ command! NERDTreeMirrorOpen call <SID>NERDTreeMirrorOrCreate()
command! NERDTreeMirrorToggle call <SID>NERDTreeMirrorToggle()
command! NERDTreeSteppedOpen call <SID>NERDTreeSteppedOpen()
command! NERDTreeSteppedClose call <SID>NERDTreeSteppedClose()
command! NERDTreeFocusToggle call <SID>NERDTreeFocusToggle()
"
" }}}
" === plugin functions === {{{
Expand Down Expand Up @@ -199,6 +201,23 @@ fun! s:NERDTreeSteppedClose()
endif
endfun

" }}}
" s:NERDTreeFocusToggle() {{{
"
" focus the NERDTree view or creates it if in a file,
" or unfocus NERDTree view if in NERDTree
fun! s:NERDTreeFocusToggle()
let s:disable_handlers_for_tabdo = 1
if s:IsCurrentWindowNERDTree()
call s:NERDTreeUnfocus()
else
if !s:IsNERDTreeOpenInCurrentTab()
call s:NERDTreeOpenAllTabs()
endif
call s:NERDTreeFocus()
endif
let s:disable_handlers_for_tabdo = 0
endfun
" }}}
"
" === NERDTree manipulation (opening, closing etc.) === }}}
Expand Down

0 comments on commit d446627

Please sign in to comment.