0

Since about 2 weeks ago, when I open a file in a new tab in NerdTree it is extremly slow, it takes about to seconds to open the file.

The file size doesnt matter, even if I open a file with 1 line in it, it still takes the same amount of time. If I open the file in the current tab it is instant. If I use vims built in explore and tab open it is instant.

I have the following config for NERDTREE in my .vimrc:

" Find
map <Leader>v :NERDTreeFind<CR>
" Toggle
map <Leader>f :NERDTreeToggle<Enter>

" Close Automatically
let NERDTreeQuitOnOpen = 1

" Automatically delete the buffer of the file you just deleted with NerdTree:
let NERDTreeAutoDeleteBuffer = 1

let NERDTreeShowHidden=1  " show hidden files in nerdtree
let NERDTreeShowBookmarks=1 " Display NERDTree Bookmarks

"NERDTree filter out file extentions
let NERDTreeIgnore = ['\.swo$', '\.swp$']

Vim Version:

VIM - Vi IMproved 8.1 (2018 May 17, compiled May 25 2018 00:50:25)

I have uninstalled and installed NERDTree. I am struggling to troubleshoot this. Any suggestions ?

Narayana
  • 323
  • 3
  • 16
  • 1
    Open a file then call `:messages` to check if there are any error messages? I've had this once but it was just a plugin I recently installed. Through a process of elimination, try disable some plugins to see when it stops. Most like has something to do with syntax highlighting. – FanManPro Jul 28 '18 at 18:12
  • If the delay is also there when you open the file from the terminal (e.g. `vim file.txt`), then it probably has nothing to do with NERDTree. – FanManPro Jul 28 '18 at 18:14

1 Answers1

0

After manualing commenting everything in my vimrc.(I made a backup on git). I debugged my .vimrc chunk by chunk and found the my tab shortcuts to be the culprit:

" Tab cycle
nnoremap th  :tabfirst<CR>
nnoremap tk  :tabnext<CR>
nnoremap tj  :tabprev<CR>
nnoremap tl  :tablast<CR>
nnoremap tt  :tabedit<Space>
nnoremap tn :tabnew<CR>
nnoremap tm  :tabm<Space>
nnoremap td  :tabclose<CR>

I suspect because I was using "t" to open a new tab and the tab cycle shortcut was similar, maybe that caused the delay?

Narayana
  • 323
  • 3
  • 16
  • `t` is such a useful command (See `:h t`). Are you sure you really want to override it? – Peter Rincker Jul 30 '18 at 14:21
  • Interesting. Thanks. I am using space + j/k or space +1/2/3 to switch tabs now – Narayana Jul 30 '18 at 19:00
  • 1
    I feel like you might be doing a tab-centric workflow. Nothing wrong with that, but you might want to look at buffers some more. Some reading material: [Using Vim's tabs like buffers](https://stackoverflow.com/q/102384/438329), [Why do Vim experts prefer buffers over tabs?](https://stackoverflow.com/q/26708822/438329), [Use buffers effectively](https://stackoverflow.com/a/21338192/438329), [Intresting comment on r/vim](https://www.reddit.com/r/vim/comments/8wir4r/some_lesserknown_vim_tips_from_8_years_of_use/e1wkfvj/?context=3). – Peter Rincker Jul 30 '18 at 20:54
  • Ha funny I just discovered buffers. I find it very similar to tabs. I am trying to adapt. Thanks :) – Narayana Jul 31 '18 at 18:54
  • Ahh I just had a light build moment. I didnt really see the benefit of using buffers but it just hit me now. Buffers are superior to tabs when working with multiple files in multiple windows. As you can arrange any buffer(file) to be open in any window and all buffers are shared to be arranged and used in anyway. Where with tabs you can only work with a set number of files in a tab. – Narayana Jul 31 '18 at 19:03