I opened two files using -O
vim file1 file2 -O
it opens the files horizontally aligned but I dont know how switch between them ?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
Ctrl + 'w' + 'r' to switch to the left side
Ctrl + 'w' + 'l' to switch to the right side
Generally, Ctrl + 'w' + 'r' works to get to either side.
See https://linuxhint.com/how-to-use-vim-split-screen/ for further commands.
Use the Ctrlw + w command to move the cursor to the next window. (Also possible: Ctrlw + Ctrlw, pressing it twice.)
This command will cycle through windows to the right, then towards the bottom (in the same order you'd read the letters on a line, then the lines on a page), finally going back to the top-left window when done traversing them.
If you only have two windows, it will simply switch between them.
The fact that you can access this command by pressing the same key twice (even while holding down the Ctrl key) makes it the most convenient way to navigate through windows in Vim.
:help CTRL-W_w for more details.
There are also many other window commands that use Ctrlw as a prefix. For example, you can use the typical movement commands (
l) to move the cursor to a window in that specific direction (left, down, up and right, resp.) See
:help windows for a full list of commands and options related to windows in Vim.