I found the window manager in vim is quite powerful. We can use it to split the window to whatever we want it to be. But when the numbers of the windows comes to more then 4, it will caused one problem: it's quit hard to jump to the rightmost window. Because the rightmost window is used to display taglist in my vim. I don't like the way that type CTRL+w for twice or more times to jump to the rightmost window. Is there a more easier way to do it?
:nmap <C-\> <C-w>200l
then you press ctrl-\ will let you go to the most right window.
actually you don't need to press c-w many times. if you have 10 windows opened, and now you are in 3rd window, you just type ctrl-w 10 l. to go to the right most window.
from help:
CTRL-W_l| CTRL-W l go to Nth right window (stop at last window)
you just need give a N
If the previous window was TagList, you can use <C-w>p to jump to it.
You can also use <C-w>b to jump to the last window at the bottom-right.
Related
How to fast change focus between windows in neovim? I dont know how to make it.
A quick reference from usr_08.txt
CTRL-W h move to the window on the left
CTRL-W j move to the window below
CTRL-W k move to the window above
CTRL-W l move to the window on the right
CTRL-W t move to the TOP window
CTRL-W b move to the BOTTOM window
If you're a new user (and have done vimtutor), I highly recommend going through the user manual (or at least skim through it, so that you learn the basics of Vim) - :h user-manual.
Both for Vim and NeoVim, why don't you give a try to this plugin I've created to allow easy movement between, and "management" of, windows and tabs?
I you go to that page, you'll see I've included a GIF showing the keys I press and what they do. Essentially you press leader+w to enter a "window management"-mode which interprets any key as if it was preceded by Ctrl-W.
I am using Vim and I am unable to switch to one of my windows by using the default bind keys <ctrl+w> j. I have three windows open and the bottom right window is inaccessible. Why is this happening?
<ctrl> + w + w works for me.
If you :sp or :vsp to split a pane, <ctrl> + w + w will allow you to navigate between them.
It appears as if you have taken something similar to the following course of action
vim <some-file>
:vs <some-other-file>
<C-w> l // to get to the right window
:term // to open up a terminal session within right right window
<C-w> j // to move to the bottom right window (a normal vim window)
:q
vim <file> // within the terminal inside the right vim window
:sp <file> // split that window
Now it will appear as if you have three vim windows, when in reality, you have four:
Two outer (the left, and the right terminal session)
Two within the right window's terminal session
This is quite a precarious position because whether you are in the outer left or right session, the outer buffer (not sure if this is the correct word so please correct me if I'm wrong) will always captures the <C-w> control character for some reason.
You can see this by looking where the <C-w> shows up on the screen when you press it. If I have replicated your environment correctly, it shows up in the bottom right corner below the outer buffer's right window.
As a workaround to this, instead of using <C-w> to proc window navigation, you need to use:
:winc j
to navigate to the bottom right window.
I am using vim editor and have split windows using vsplit. I have 3 vertical split windows in A B C order. Is it possible to shuffle the windows to B A C order?
Use <ctrl-w> + H to move the currently selected window to the far left (Upper case H)
So if you cursor was in pane B you could do <c-w>H to move B left and A will take its place in the middle
Take a look at :h window-moving for other options in moving windows around.
5. Moving windows around window-moving
CTRL-W x CTRL-W_x CTRL-W_CTRL-X
CTRL-W CTRL-X Without count: Exchange current window with next one. If there
is no next window, exchange with previous window.
With count: Exchange current window with Nth window (first
window is 1). The cursor is put in the other window.
When vertical and horizontal window splits are mixed, the
exchange is only done in the row or column of windows that the
current window is in.
...
CTRL-W_H
CTRL-W H Move the current window to be at the far left, using the
full height of the screen. This works like closing the
current window and then creating another one with
":vert topleft split", except that the current window contents
is used for the new window.
{not available when compiled without the +vertsplit feature}
if you want to achieve ABC->BAC, cursor in B, do #Fdinoff suggested, if cursor in A, <c-w> +x exchange current window with next one.
Personally I used it often when I opened two windows side by side, and want to exchange their positions.
<c-w> H is also useful to switch H-split two windows to V-split.
Interesting question. If I really would like to have vim shuffle the windows, I
would do it like this:
au VimEnter * exe (localtime()%winnr('$')+1). "wincmd R|1wincmd w"
I have the problem with splitting windows. If I open a file with :split the size of the new window includes only one line. I don't know why.
Is there a way to resize the window in vim as I need it?
jump into the window you want to resize (ctrl-w ctrl-w OR ctrl-w direction-arrow), then hit ctrl-w followed by [number followed by] + (or - if you want to decrease the size)
the number is optional and indicates how many "units" you want to enlarge the window by, defaults to 1 if not specified
Or just hit ^W= to make all windows roughly same-size.
Also, :se mouse+=a should enable you to just drag the dividers with the mouse, even on terminal emulators across a GNU screen session.
I often have several windows open at once in Vim: one is my code, one is a side-bar, one is the open quickfix window on bottom.
Whenever I close the bottom window with <C-W> C, the cursor is moved to the side-bar, as it is on the left.
Is there a way I can make the cursor instead move to the main window on the right?
You could remap the close command to always go back to the previous window:
:nnoremap <C-w>c <C-w>c<C-w>p
You said that the bottom window is quickfix. You don't have to move your cursor to that window, then type C-W c to close it. You could leave your cursor in your main window (above one), then :cclose, the quickfix window gets closed, and your cursor stays in where it was.
:h cclose to see detail. also you could make a mapping for that if use that often.
I am not sure if you would accept this.