I am using vim-airline plugin which works pretty good however, the only way to switch between tabs is to user :bp or :bn which is shortcuts for :bprevious or :bnext. The problem with this is that if I am on first tab and want to switch to the last tab i.e. 10th tab then I have to type :bn ten times to get there. How can I switch directly? Maybe something pressing arrow keys would be beneficial.
Your problem is that you installed a plugin designed to obfuscate Vim's regular commands and workflows without even knowing those regular ways. The shortcut you took lead you to a dead-end so your only reasonable solution is to go back to the main road and learn Vim properly, without training wheels and crutches.
So… from your question, it seems you are using Airline's so-called "smarter tabline" which displays your open buffers in a fake tabline.
If it was a real tabline, they would actually be tab pages and you would move between them with their own set of commands.
But they are buffers and yes, you are supposed to move between them with these commands:
:bnext
:bprevious
:bfirst
:blast
:b10
:b <buffer-name>
which can all be mapped for your convenience, of course.
But… that plugin doesn't show buffer numbers, so you can't use :b10 to jump reliably to the tenth buffer in your fake "tabline" so that's one less tool in your tool-belt.
And some special buffers, like the quickfix list, can be reached with :bn/:bn without — probably — being listed in your fake "tabline" so that makes your fake "tabline" a rather poor abstraction, even without considering the glaring limitations of tabs in general.
And there's the idiosyncratic behavior of that fake "tabline" which becomes a semi-real "tabline" when you actually use tab pages.
Conflating two very different — and powerful in their own ways — concepts into a single bastardized one is not really a good idea.
I suggest you disable that option and use buffers and tab pages as they are meant to be used.
Reference:
:help buffers
:help tab-page
Agree with #romainl but you can always map your +tab to :bn or :bp for your ease.
" Tab navigation like Firefox.
nnoremap <C-S-tab> :bprevious<CR>
nnoremap <C-tab> :bnext<CR>
In addition to Rafi's answer, put this in your .vimrc to get direct access to a buffer / airline tab.
nmap <leader>1 :bfirst<CR>
nmap <leader>2 :bfirst<CR>:bn<CR>
nmap <leader>3 :bfirst<CR>:2bn<CR>
nmap <leader>4 :bfirst<CR>:3bn<CR>
...
Alternatively, you can double down on airline with
let g:airline#extensions#tabline#buffer_idx_mode = 1
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
if you are using vim-airline, I'm strongly suggested that to using AirlineSelectTab command, you can see it via :help airline, below is the configuration.
let g:airline#extensions#tabline#buffer_idx_mode = 1
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
nmap <leader>0 <Plug>AirlineSelectTab0
nmap <leader>- <Plug>AirlineSelectPrevTab
nmap <leader>+ <Plug>AirlineSelectNextTab
If you are using tabs instead of buffers
" Tab navigation (works only in gvim, not in console)
nnoremap <C-tab> gt
nnoremap <C-S-tab> gT
I have configured vim to switch between tabs using Ctrl + arrow keys.
Ctrl + ← will switch to tab that is on the left of current tab.
Ctrl + → will switch to tab that is on the right of current tab.
Ctrl + ↑ will switch to first tab.
Ctrl + ↓ will switch to last tab.
To achieve above behaviour update your vimrc with following lines:
nnoremap <C-Left> :tabprevious<CR>
nnoremap <C-Right> :tabnext<CR>
nnoremap <C-Up> :tabfirst<CR>
nnoremap <C-Down> :tablast<CR>
This works with vim-airline plugin as well.
Reference: Using vim tab pages
Related
I currently map my F2 and F3 as following:
map <F2> :tabn <CR>
map <F3> :tabp <CR>
imap <Esc> :tabn <CR>
imap <Esc> :tabp <CR>
I try to figure out how to map the normal/insert mode at the same time.
I spent some times on googling around without any luck.
Any suggestion would be appreciated.
The best I've found so far is:
nnoremap <F2> :tabn<CR>
imap <F2> <C-O><F2>
nnoremap <F3> :tabp<CR>
imap <F3> <C-O><F3>
Still an extra line for each key, but at least the actual command (:tabn, :tabp) is only mentioned once (and only needs to be changed in one place if you want to change it).
Honestly in my opinion, these mappings are probably not worth it.
gt/gT already exist to move between tabs. See :h gt
Normal mode is crucial to Vim and it makes sense to use this mode and not insert mode for movement between tabs. It is called normal mode for a reason as it is the mode you should normally be in.
Aside about tabs and buffers
Your mappings suggest a heavy tab centric workflow. I know it might sound weird but maybe try and use less tab panes together with a more buffers centric workflow. Here are some nice posts about it:
Why do Vim experts prefer buffers over tabs?
Use buffers effectively!
NOTE: I am using Terminator instead of terminal. But as all other mappings are working fine why does these are not working.
I have tried to use these mappings in my vimrc file to be able to use Tab Navigation. But its not working at all.
nnoremap <C-S-tab> :tabprevious<CR>
"nnoremap <C-tab> :tabnext<CR>
nnoremap <C-tab> :tabn<CR> "I also tried this
nnoremap <C-t> :tabnew<CR>
inoremap <C-S-tab> <Esc>:tabprevious<CR>i
inoremap <C-tab> <Esc>:tabnext<CR>i
inoremap <C-t> <Esc>:tabnew<CR>
inoremap <C-S-w> <Esc>:tabclose<CR>
"Also to go to the nth tabpage Use <A-Fn>
nnoremap <A-F1> 1gt
nnoremap <A-F2> 2gt
nnoremap <A-F3> 3gt
nnoremap <A-F4> 4gt
nnoremap <A-F5> 5gt
nnoremap <A-F6> 6gt
nnoremap <A-F7> 7gt
nnoremap <A-F8> 8gt
nnoremap <A-F9> 9gt
nnoremap <A-F10> 10gt
NOTE: I have ctags and cscope installed. So I think there might be some confliction as ctrl-t is to jump back from a certain tag. And only this mapping is working for new tab.
Also I have checked ctrl-PageDown is working fine for the same purpose.
2nd Question:
How does this key notation works in vimrc.
Is it something like this:
All modifier keys should be used in Caps like
C for Ctrl.
A for Alt.
S for Shift.
And other keys are all in small.
But what about keys like:
Home
End
Backspace
Escape
PageUp
PageDown
Tab
Function keys etc.
How to use them?
Here
I read that how these should be used in mapping but even they have used tab instead of Tab in mappings.
Brace yourself for disappointment.
The terminal keycodes
Vim accepts terminal keycodes, so not all key combinations are possible. The best way to figure out which keys are recognizable is to open insert mode and press ctrl+v followed by your key combination. This will show you the raw codes. Do this for another key combination. If the raw codes are the same then Vim can not distinguish between them. e.g. ctrl+v ctrl+shift+tab.
Your mappings
You should probably avoid doing insert mode mappings to switch tabs. It simply isn't the Vim Way as insert mode should only be used in short bursts.
Your :tabprev and :tabnext mappings can simplified into gT and gt mappings. Personally I do not mind the default gt or gT mappings.
<key> notation
As far as I know the case does not matter. All my mappings are lowercase. For a list of <> notation please see :h key-notation.
You are correct on the <c-..> for control, <a-...> for alt, and <s-...> for shift. Example combination would be <c-s-space>. Note: most <c-s-...> mappings are going to fail.
Using Tabs
Vim's tabs are not like most text editors tab. They are more like viewports into a group of windows/splits. Additionally, Vim is buffer centric, not tab centric like most editors. For example using features like Vim's quickfix list is often easier without tabs (See :h 'switchbuf if you must use tabs). Vim's tabs often get in the way of using a splits as there are better window and buffer navigation commands available. I personally have many files open (sometimes 100+) using no tabs and use on average 1-2 splits without any issue.
Bottom line: Learn to use buffers effectively.
Conclusion
I would suggest you break this tab workflow quickly and learn to love buffers. You won't really need your mappings and you will not be working against Vim's nature.
Read :help key-notation for an explanation of… Vim's key notation.
It is generally a good idea to play it safe so I recommend to follow these conventions when mapping combos:
always use an uppercase letter for the modifier key, C for Control, S for Shift, A for Alt, D for Command (MacVim GUI only), M for Meta,
always use a lowercase letter for the alphabetical keys, abc…xyz,
always capitalize the first letter of "special" keys, Tab, Space, Up, etc.
Examples:
<S-Up>
<C-r>
<A-LeftMouse>
However, the following notation works just as well so… whatever notation you choose, try to be consistent:
<s-UP>
Using multiple modifiers in a single mapping doesn't work reliably so you will be better in the long run if you completely avoid them.
nnoremap <C-S-j> :echo "csj"<CR>
nnoremap <C-j> :echo "cj"<CR>
now press <C-j> and <C-S-j> in normal mode.
<C-S-w> is indistinguishable from <C-w>.
:verbose map <C-t>
shows you what is mapped to <C-t> and where the mapping occurred. You can use it to debug your mappings.
And I agree with Peter, you are using both tab pages and insert mode wrongly.
I normally work with more than 5 files at a time. I use buffers to open different files.
I use commands such as :buf file1, :buf file2 etc.
Is there a faster way to move to different files?
What I use:
Go to the previous buffer: :b# or :bp
Go to the next buffer: :bn
If you know your file is loaded in buffer 5: :b5
To get a list of buffers: :buffers or shorter: :ls
And have a short look on :he buffer
And the wiki entry on Easier Buffer Switching on the Vim Wiki: http://vim.wikia.com/wiki/Easier_buffer_switching
SO already has a question regarding yours: How do you prefer to switch between buffers in Vim?
A few mappings can make your life a lot easier.
This one lists your buffers and prompts you for a number:
nnoremap gb :buffers<CR>:buffer<Space>
This one lists your buffers in the "wildmenu". Depends on the 'wildcharm' option as well as 'wildmenu' and 'wildmode':
nnoremap <leader>b :buffer <C-z>
These ones allow you to cycle between all your buffers without much thinking:
nnoremap <PageUp> :bprevious<CR>
nnoremap <PageDown> :bnext<CR>
Also, don't forget <C-^> which allows you to alternate between two buffers.
Below I describe some excerpts from sections of my .vimrc. It includes mapping the leader key, setting wilds tab completion, and finally my buffer nav key choices (all mostly inspired by folks on the interweb, including romainl). Edit: Then I ramble on about my shortcuts for windows and tabs.
" easier default keys {{{1
let mapleader=','
nnoremap <leader>2 :#"<CR>
The leader key is a prefix key for mostly user-defined key commands (some plugins also use it). The default is \, but many people suggest the easier to reach ,.
The second line there is a command to # execute from the " clipboard, in case you'd like to quickly try out various key bindings (without relying on :so %). (My nmeumonic is that Shift-2 is #.)
" wilds {{{1
set wildmenu wildmode=list:full
set wildcharm=<C-z>
set wildignore+=*~ wildignorecase
For built-in completion, wildmenu is probably the part that shows up yellow on your Vim when using tab completion on command-line. wildmode is set to a comma-separated list, each coming up in turn on each tab completion (that is, my list is simply one element, list:full). list shows rows and columns of candidates. full's meaning includes maintaining existence of the wildmenu. wildcharm is the way to include Tab presses in your macros. The *~ is for my use in :edit and :find commands.
" nav keys {{{1
" windows, buffers and tabs {{{2
" buffers {{{3
nnoremap <leader>bb :b <C-z><S-Tab>
nnoremap <leader>bh :ls!<CR>:b<Space>
nnoremap <leader>bw :ls!<CR>:bw<Space>
nnoremap <leader>bt :TSelectBuffer<CR>
nnoremap <leader>be :BufExplorer<CR>
nnoremap <leader>bs :BufExplorerHorizontalSplit<CR>
nnoremap <leader>bv :BufExplorerVerticalSplit<CR>
nnoremap <leader>3 :e#<CR>
nmap <C-n> :bn<cr>
nmap <C-p> :bp<cr>
The ,3 is for switching between the "two" last buffers (Easier to reach than built-in Ctrl-6). Nmeuonic is Shift- 3 is #, and # is the register symbol for last buffer. (See :marks.)
,bh is to select from hidden buffers (!).
,bw is to bwipeout buffers by number or name. For instance, you can wipeout several while looking at the list, with ,bw 1 3 4 8 10 <CR>. Note that wipeout is more destructive than :bdelete. They have their pros and cons. For instance, :bdelete leaves the buffer in the hidden list, while :bwipeout removes global marks (see :help marks, and the description of uppercase marks).
I haven't settled on these keybindings, I would sort of prefer that my ,bb was simply ,b (simply defining while leaving the others defined makes Vim pause to see if you'll enter more).
Those shortcuts for :BufExplorer are actually the defaults for that plugin, but I have it written out so I can change them if I want to start using ,b without a hang.
You didn't ask for this:
If you still find Vim buffers a little awkward to use, try to combine the functionality with tabs and windows (until you get more comfortable?).
" windows {{{3
" window nav
nnoremap <leader>w <C-w>
nnoremap <M-h> <C-w>h
nnoremap <M-j> <C-w>j
nnoremap <M-k> <C-w>k
nnoremap <M-l> <C-w>l
" resize window
nnoremap <C-h> <C-w><
nnoremap <C-j> <C-w>+
nnoremap <C-k> <C-w>-
nnoremap <C-l> <C-w>>
Notice how nice ,w is for a prefix. Also, I reserve Ctrl key for resizing, because Alt (M-) is hard to realize in all environments, and I don't have a better way to resize. I'm fine using ,w to switch windows.
" tabs {{{3
nnoremap <leader>t :tab
nnoremap <M-n> :tabn<cr>
nnoremap <M-p> :tabp<cr>
nnoremap <C-Tab> :tabn<cr>
nnoremap <C-S-Tab> :tabp<cr>
nnoremap tn :tabe<CR>
nnoremap te :tabe<Space><C-z><S-Tab>
nnoremap tf :tabf<Space>
nnoremap tc :tabc<CR>
nnoremap to :tabo<CR>
nnoremap tm :tabm<CR>
nnoremap ts :tabs<CR>
nnoremap th :tabr<CR>
nnoremap tj :tabn<CR>
nnoremap tk :tabp<CR>
nnoremap tl :tabl<CR>
" or, it may make more sense to use
" nnoremap th :tabp<CR>
" nnoremap tj :tabl<CR>
" nnoremap tk :tabr<CR>
" nnoremap tl :tabn<CR>
In summary of my window and tabs keys, I can navigate both of them with Alt, which is actually pretty easy to reach. In other words:
" (modifier) key choice explanation {{{3
"
" KEYS CTRL ALT
" hjkl resize windows switch windows
" np switch buffer switch tab
"
" (resize windows is hard to do otherwise, so we use ctrl which works across
" more environments. i can use ',w' for windowcmds o.w.. alt is comfortable
" enough for fast and gui nav in tabs and windows. we use np for navs that
" are more linear, hjkl for navs that are more planar.)
"
This way, if the Alt is working, you can actually hold it down while you find your "open" buffer pretty quickly, amongst the tabs and windows.
Once the buffers are already open, you can just type :b partial_filename to switch
So if :ls shows that i have my ~./vimrc open, then I can just type :b vimr or :b rc to switch to that buffer
There are many ways to solve. The best is the best that WORKS for YOU. You have lots of fuzzy match plugins that help you navigate. The 2 things that impress me most are
1) CtrlP or Unite's fuzzy buffer search
2) LustyExplorer and/or LustyJuggler
And the simplest :
:map <F5> :ls<CR>:e #
Pressing F5 lists all buffer, just type number.
I'd like to bind these:
CTRLF one character forward
CTRLB one character backward
CTRLN go to the line below the current one ( not in insert mode )
CTRLP go to the line above the current one ( not in insert mode )
Which functions should I bind? How could I find them?
On vim.org you can find a script called Vimacs : Vim-Improved eMACS: Emacs emulation for Vim
The short description says:
Vimacs (Vim-Improved eMACS) brings Emacs's extensive key bindings and modeless editing features to the Vim world, while completely retaining Vim's powerful moded editing style.
So I guess this is all you need.
If you just want those four mappings and not the full Vimacs, you can do this:
nmap <c-f> l
nmap <c-b> h
nmap <c-n> j
nmap <c-p> k
To get ctrl-f and ctrl-b to work in insert mode add these:
imap <c-f> <right>
imap <c-b> <left>
Check out the map command.
:h :map
You might want to consider learning the vim mappings. (h/l and j/k are shorter than ctrl-f/ctrl-b and ctrl-n/ctrl-p).
Also, check out..
:h index
.. for a list of the mappings.
I've tried MiniBufExplorer, but I usually end up with several windows showing it or close it altogether. What I'd like is something like LustyJuggler with incremental search, the way I switch between buffers in Emacs. Surely there is a script like this?
I used to use a combination of tabs and multiple gvim instances, keeping groups of related files as tabs in each instance. So long as I didn't end up with too many tabs in one instance, the tab bar shows you the name of each file you're editing at a glance.
Then I read a post by Jamis Buck on how he switched from TextMate back to vim, and learned some great tricks:
Ctrl+w s and Ctrl+w v to split the current window
Ctrl+6 to switch back and forth between two buffers in the same window.
the awesome fuzzyfinder.vim which gives you auto-completing search of files in your current directory or of buffers you currently have open
Jamis' own fuzzy_file_finder and fuzzyfinder_textmate, which slightly modify how fuzzyfinder works to behave more like a similar feature in TextMate (as far as I can tell, the difference is that it matches anywhere in the filename instead of only from the start). Watch this video to see it in action.
Now I just have one gvim instance, maximised, and split it into multiple windows so I can see several files at once. I bound Ctrl+F to fuzzyfinder\_textmate, so now if I type (say) Ctrl+F mod/usob it opens up app/models/user\_observer.rb. I almost never bother with tabs any more.
Update 2010/08/07
While fuzzyfinder\_textmate remains awesome, as Casey points out in the comments, it's no longer maintained. Also, it (and/or fuzzyfinder.vim) gets a bit slow and unstable when working with large projects (lots of directories or files), so I've been looking for an alternative.
Fortunately, there seems to be a very nice alternative in the form of Wincent Colaiuta's Command-T plugin. This has very similar (if not slightly better) behaviour to fuzzyfinder\_textmate, but is noticeably faster; it also has nice features like being able to open the found file in a split or vertical split. Thanks (and upvotes!) to David Rivers for pointing to it.
I use the basics - ':ls' + ':bn'/':bp' + ':b <part-of-name>'
I like "ctrl-w s" and "ctlr-w v" to split the window. Then I map the movement keys (h, j, k, l) with ctrl held down to move between the split windows:
" Map ctrl-movement keys to window switching
map <C-k> <C-w><Up>
map <C-j> <C-w><Down>
map <C-l> <C-w><Right>
map <C-h> <C-w><Left>
Having to move my hand over to the arrow keys is annoying.
Next, I set up ctlr-tab to switch between buffers in the current window (like a lot of other environments):
" Switch to alternate file
map <C-Tab> :bnext<cr>
map <C-S-Tab> :bprevious<cr>
These have worked pretty well for me over the last several years although vim always has more secrets than you can know.
I have been using Wincent Colaiuta's Command-T vim plugin for a couple months now. Wincent wrote the parts of it that need to be fast in C, and I must say that it is! And, I think its file pattern matching logic is even better than Textmate's Command-T. Check out the screencast.
The Command-T plug-in for VIM provides
an extremely fast, intuitive mechanism
for opening files with a minimal
number of keystrokes. It's named
"Command-T" because it is inspired by
the "Go to File" window bound to
Command-T in TextMate.
Files are selected by typing
characters that appear in their paths,
and are ordered by an algorithm which
knows that characters that appear in
certain locations (for example,
immediately after a path separator)
should be given more weight.
Easier buffer switching contains many useful tips. I have adapted the following to my .vimrc, which does buffer-name auto-completion, maps the most useful buffer-switching commands to my <Leader> and left-side home row keys, and shows the current buffer number in the status line:
"" Tab triggers buffer-name auto-completion
set wildchar=<Tab> wildmenu wildmode=full
let mapleader = ","
map <Leader>t :CommandT<Return>
map <Leader>a :bprev<Return>
map <Leader>s :bnext<Return>
map <Leader>d :bd<Return>
map <Leader>f :b
"" Show the buffer number in the status line.
set laststatus=2 statusline=%02n:%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
I also use MiniBufExplorer, which provides a compact listing of each listed buffer in its own horizontal split up top.
nmap <Leader>bb :ls<CR>:buffer<Space>
and nobody mentioned nice plugin ctrlp.vim. Using this plugin you can search buffer by name.
I use
CTRL-J for next buffer
CTRL-K for previous buffer
CTRL-L for next tab
CTRL-H for previous tab
Here is the .vimrc configuration:
map <C-J> :bnext<CR>
map <C-K> :bprev<CR>
map <C-L> :tabn<CR>
map <C-H> :tabp<CR>
See http://syskall.com/my-biggest-vim-productivity-boost/
imap <A-1> <Esc>:tabn 1<CR>i
imap <A-2> <Esc>:tabn 2<CR>i
imap <A-3> <Esc>:tabn 3<CR>i
imap <A-4> <Esc>:tabn 4<CR>i
imap <A-5> <Esc>:tabn 5<CR>i
imap <A-6> <Esc>:tabn 6<CR>i
imap <A-7> <Esc>:tabn 7<CR>i
imap <A-8> <Esc>:tabn 8<CR>i
imap <A-9> <Esc>:tabn 9<CR>i
map <A-1> :tabn 1<CR>
map <A-2> :tabn 2<CR>
map <A-3> :tabn 3<CR>
map <A-4> :tabn 4<CR>
map <A-5> :tabn 5<CR>
map <A-6> :tabn 6<CR>
map <A-7> :tabn 7<CR>
map <A-8> :tabn 8<CR>
map <A-9> :tabn 9<CR>
I've recently gone more minimalistic.
To cycle buffers I use ]b and [b from unimpaired: https://github.com/tpope/vim-unimpaired
To jump straight to an open buffer just use Vim's tab completion with :b. A few letters is enough to get to any open buffer with a tab or two.
Similarly to open buffers I use :e with relative paths and tab complete.
I also use :ls occasionally to see what buffers I have open (and to check their modified status).
To get rid of a buffer I use :bw to wipe the buffer. I usually make a temporary split and change buffers to preserve my layout though since :bw also closes the active window.
All the minibuf things I tried just ended up annoying me, and I don't want some smart-matching thing opening random files for me. If I really need to browse for something I use NERDtree (:e .).
IDK, Lately I also dropped Yankring (because it screws up xp) and started using registers, and I recently decided the f/t movements are the greatest thing ever...
To list and switch between buffers I use:
nnoremap <Leader>l :ls<CR>:b<space>
To switch between buffers:
map <Leader>n :bn<CR>
map <Leader>p :bp<CR>
The excellent Buffer Explorer, the be has gotten to be such strong muscle memory that I find myself wishing I could use it in other applications. I find it to be extremely fast when actively editing more than two files.
I've spent quite a while building my .vimrc to work with this HTML::Mason project I've been on for four years, so I have an odd mix of tabs and split windows. For your viewing enjoyment:
map ;o :Sex <CR>
map <C-J> <C-W>j
map <C-K> <C-W>k
map <C-l> <C-W>l
map <C-h> <C-W>h
map ;] :tabnext<CR>
map ;[ :tabprev<CR>
map <C-t> :tabe +"browse ."<CR>
map <C-O> :NERDTreeToggle ~/curr/trunk/<CR>
I use tselectbuffer. It's really fast and unlike bufexplorer doesn't take space in your window. It also has a incremental search.I tried minibufexplorer and I found the navigation in the buffer a bit difficult.
I have mapped <S-J> and <S-K> to :bp and :bn, although I admit I don't use it as the number of files is greater than 10. I have then mapped <C-J> and <C-K> to Gnome Terminal's previous and next tabs, and I usually run 4 instances of vim for each of the 4 different projects I work on. I still really wish next and previous buffer would go to the history of buffers I have been working on, and not the order int he buffer list.
I use tselectbuffer. It's really fast and unlike bufexplorer doesn't take space in your window. It also has a incremental search.I tried minibufexplorer and I found the navigation in the buffer a bit difficult.
i use simple :vsplit with ^W+w/^W+r and :tabnew with Ctrl+Alt+PgUp/PgDown key combinations.
When there are several buffers open in a Vim session, it can become difficult to keep track of the buffers and their respective buffer numbers. If this is the case, switching to a different file can be made easier using a simple map:
:nnoremap (F5) :buffers(CR):buffer(Space)
vim.wikia.com