0

I am using the NERDTree and NERDTree tabs plugin. In order to move between tabs I found these shortcuts which work fine:

nnoremap tp :tabprev<CR>
nnoremap tn :tabnext<CR>
nnoremap tf :tabfirst<CR>
nnoremap tl :tablast<CR>

However, I also want ability to re-arrange tabs. Searching online, i found the following:

" useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove

I have included the above in my .vimrc file but don't understand how to use them. What is mean ? How do I rearrange tabs using the above commands or are these commands useless ?

runtimeZero
  • 26,466
  • 27
  • 73
  • 126
  • Why don't you have a look at `:help :tabnew`, `:help :tabonly`, `:help :tabclose` and `:help :tabmove`? – OhleC Sep 30 '14 at 13:32

1 Answers1

0

You can execute one of these command by pressing your leader key then the rest of the mapping. The default leader key is \ so your first mapping would be \tn. You can see what is mapped to what by issuing the :map command with out any agruments. You can narrow this down by mode for example by doing :nmap, :imap, or :vmap. You can also supply one argument which will narrow down the results much further. e.g. :nmap \ will show all normal mappings that start with \.

However there are a few concerns with your mappings:

  • You should supply a mode with your mappings
  • Unless you have a good reason it should be a in noremap form. e.g. nnoremap <leader>tn :tabnew<cr>
  • Your tp, tn, tf, and tl overshadow the the t command which is quite handy
  • gt and gT are the default tab tabnext/tabprev mappings.
  • You seem to be making heavy use of Vim's tab. It should be noted that Vim's tabs serve a different purpose than that of other editors. See: Using Vim's tabs like buffers
  • As you don't seem know about the t command I am going to suggest you take a look at vimtutor. See :h tutor or run vimtutor from the command line.
  • It might also be wise to forgo some of the plugins until you get a better grip on how Vim works.
  • You may want to reconsider the use of NerdTree as Vim does not support the "drawer" and it will interfere with windows/splitting. See: Oil and vinegar - split windows and the project drawer

For more information see:

:h <leader>
:h t
Community
  • 1
  • 1
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101
  • NerdTree is a fine plugin however there are issues which stick out like a sore thumb when NerdTree is used as an "always on" project drawer. 1) It makes splitting and window navigation trickier 2) It wastes space because it is not likely needed to see the file structure anywhere near 100% of the time. I have another answer that might help clarify these issues and how to address them: [Files, Buffers, and Splits Oh My!](http://stackoverflow.com/a/23121220/438329). – Peter Rincker Sep 30 '14 at 19:20