How to make shortcut for :tabnew, :tabn, :tabp?

Viewed 13251

In vim, I'd like to shorten :tabnew to :tn, :tabp to :th, :tabn to :tl somewhere in my .vimrc. Any idea how I would remap commands like this?

7 Answers

If you want to keep the same mapping that is suggested here, https://stackoverflow.com/a/17269521/2743772, and don't want to use other suggestions, try adding leader to the beginning and this way it doesn't overwrite "t", unless of course you already have these exact mappings for something else.

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

Ctrl + PageUp and Ctrl + PageDown move between tabs by default.

The shortcuts must not be bind by the terminal for this to work. (I am on Ubuntu 18.04).

Related