Sina Sou
Sina Sou

Reputation: 159

Switching between splitted Vim windows as commands

I changed my .vimrc file to automatically open two windows once I fire $vim my_file.py So in my .vimrc file I added following lines vnew previewwindow

The problem is that I want to automatically modify each window and resize them in .vimrc and taking out the line numbers from previewwindow.

I know in vim I can switch between windows by +w but I do not know any Vim command that does so.

Is there any command such as :selectnext or :selectw previewwindow !? so the focus would switch to other window then I could apply every window specific commands.

Is there any command in vim that it accepts combined keystrokes as an argument so I can easily use that command with combined keystroke symbol to be implemented in .vimrc

In my case any command such as :sendkey( w) will work for me !? In addition I am wondering how can I prevent a window to become smaller than a certain width and height (like minimum values for w and h)? Thanks

Upvotes: 0

Views: 192

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172520

You're looking for :wincmd, so to switch to the next window (<C-W><C-W>), you'd use :wincmd w. This is a special command for window commands; in general, you can use :normal to execute normal mode commands, so :execute "normal! \<C-w>\<C-w>" would be equivalent here.

Upvotes: 1

heijp06
heijp06

Reputation: 11788

You can prepend any window movement command with :wincmd. E.g. to move the cursor to the next window you would execute:

:wincmd w

See :help window-move-cursor

Upvotes: 1

Related Questions