Skip to content

Commit 4285974

Browse files
committed
Nerd tree tabs customizations
1 parent 9420c54 commit 4285974

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

vimrc

+55-1
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,66 @@ set textwidth=110
113113

114114

115115
" NERDTree setup
116-
map <leader>t :NERDTreeToggle <CR>
116+
map <leader>T :NERDTreeToggle <CR>
117+
map <leader>t :NERDTreeTabsToggle <CR>
117118
" Was liking having drawer open up automatically, bit it's actually kind of annoying... Might modify later
118119
"autocmd vimenter * if !argc() | NERDTree | endif
119120
"autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
120121
let NERDTreeIgnore = ['\.pyc$', '\.RData$']
121122

123+
" Stuff for working with tabs + windows
124+
function! MoveToPrevTab()
125+
"there is only one window
126+
if tabpagenr('$') == 1 && winnr('$') == 1
127+
return
128+
endif
129+
"preparing new window
130+
let l:tab_nr = tabpagenr('$')
131+
let l:cur_buf = bufnr('%')
132+
if tabpagenr() != 1
133+
close!
134+
if l:tab_nr == tabpagenr('$')
135+
tabprev
136+
endif
137+
sp
138+
else
139+
close!
140+
exe "0tabnew"
141+
endif
142+
"opening current buffer in new window
143+
exe "b".l:cur_buf
144+
endfunc
145+
146+
function! MoveToNextTab()
147+
"there is only one window
148+
if tabpagenr('$') == 1 && winnr('$') == 1
149+
return
150+
endif
151+
"preparing new window
152+
let l:tab_nr = tabpagenr('$')
153+
let l:cur_buf = bufnr('%')
154+
if tabpagenr() < tab_nr
155+
close!
156+
if l:tab_nr == tabpagenr('$')
157+
tabnext
158+
endif
159+
sp
160+
else
161+
close!
162+
tabnew
163+
endif
164+
"opening current buffer in new window
165+
exe "b".l:cur_buf
166+
endfunc
167+
168+
map <C-n> :call MoveToPrevTab()<CR>
169+
map <C-m> :call MoveToNextTab()<CR>
170+
map <C-B> :call MoveToPrevTab()<CR>
171+
map <C-M> :call MoveToNextTab()<CR>
172+
" Don't know why I have to call this...
173+
unmap <enter>
174+
175+
122176
" Disables pandoc folding - kinda neet though. Might be cool to activate this later
123177
let g:pandoc_no_folding = 1
124178

0 commit comments

Comments
 (0)