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"
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 was wondering if is there any way to change the place of the tabs. Anyone can help me about this? I would like to have vim as my favourite ide..:)
Check out help :tabm[ove]. Essentially you could do:
:tabm +N to move current tab N places to the right. Or :tabm -N to move N places left.
Vim is not an IDE, it's an editor. You won't turn it into an IDE, no matter how hard you try.
Anyway, read :h tabmove:
:tabmove 0
moves the current tab to the first position
:tabmove 2
moves the current tab to after the 2 tab
:tabmove
moves the current tab to the last position
What do you exactly mean by "place of the tabs"? The other answers have already shown how to move individual tab pages around.
If you're inquiring about where Vim places the tab labels, that cannot be changed; they will always be between the GUI menu and the windows. In GVIM, you can only "downgrade" the tab appearance from graphical to textual via
:set guioptions-=e
When using the tabline (with guioptions-=e), you can drag and drop tabs with your mouse.
There is a patch pending (but not applied yet as of Vim 7.4.1054) to expand this to the GUI tabs as well:
https://groups.google.com/forum/#!msg/vim_dev/LnZVZYls1yk/fj_Gz0vhnrsJ
Split Manipulation
Ctrl+W, R (Swap top/bottom or left/right split)
Ctrl+W, T (Break out current window into a new tabview)
Ctrl+W, o (Close every window in the current tabview but the current one)
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.
In vim gf opens the file whose name is under the cursor in the current window. <C-W>f does the same but opens it in a new window. However this new window is created with an horizontal split.
How can I do the same and get a vertical split?
I tried various alternatives that did work (like :vsplit +normal\ gf), but have a slight problem: if the file doesn't exist, a new window is created anyways. This does not happen with gf nor <C-W>f. I'd like to have this behaviour as well from the "open file under cursor on a vertical split" command. How can I do that?
Here is possible mapping:
:nnoremap <F8> :vertical wincmd f<CR>
With a file name under cursor, hit F8 and voila.
Here is a solution involving 5 key strokes:
Ctrl-wv
gf
That is Ctrl-wv followed by gf in the normal mode.
Here is an equivalent solution that involves 7 key strokes:
:vs
gf
That is :vs command in command-line mode followed by gf in normal mode. Assuming we are in the normal mode with the cursor on the filename already, the complete sequence of keystrokes are: Shift:vsEntergf.
When we enter Ctrl-wv in normal mode or :vs in the command-line mode, the current window is split into two with the same file in both and the cursor remains in the same position (i.e., on the filename of the file that we want to go to in a new vertical split). So if we press gf now, the current window is now updated with the file we want to go to.
The end result is two vertical split windows: one with the first file and another with the file we wanted to go to.
If we're playing Vim Golf, I think the winning solution is to do:
Ctrl-w then f
to open the relevant file in a horizontal split.
Then change it to a vertical split, send then active window to the left or right side of the screen by doing either
Ctrl-w then L (active window to the left)
or
Ctrl-w then R (active window to the right)
Note that the final keystroke for left / right must be uppercase. The others should be lowercase