user6688317
user6688317

Reputation:

Ctrl + w + w obviously cannot perform to switch tab on a google compute engine window

Ctrl + w is a shortcut to closing an open window on VM instance of Google Compute Engine. Hence it will ask to perform that action before letting me type one more w, to enact switching of tabs between the directory tree and the script to work on in vim.

I've tried the following, as mentioned here

map  <C-l> :tabn<CR>
map  <C-h> :tabp<CR>
map  <C-n> :tabnew<CR>

While I'm not sure what tabn and tabp indicate, I tried the first two line and (C as Ctrl) neither of these respond to anything new. I used source ~/.vimrc command before expecting a change is reflected. What is wrong here?

Upvotes: 1

Views: 1658

Answers (1)

filbranden
filbranden

Reputation: 8898

I think you're mixing up Vim tabs and Vim windows.

Vim windows will split the screen vertically or horizontally into separate panes, which are all visible at the same time. That's typically used by directory tree plug-ins which want to display a navigator on a sidebar.

Vim tabs group a set of windows, so that you can switch between whole sets of windows at once and still easily go back to where you were before. (People often use tabs to work on different projects and switch between them, though opening one file per tab, fullscreen, is also a somewhat common workflow.)

The mappings that use Control-W are window mappings, not tab mappings. (You can switch to next tab with gt and previous tab with gT).

The normal commands to cycle windows are Ctrl-W w (to move right/down) and Ctrl-W W (to move left/up), so you can use these two mappings:

nnoremap <C-l> <C-w>w
nnoremap <C-h> <C-w>W

If you want a mapping to open a new window with a new blank file, you can use:

nnoremap <C-n> <C-w>n

If your problem is with typing Control-W in specific, perhaps a better option is to map a key sequence you're not using to replace Control-W, but keep it to just the prefix, so that all other commands that follow are still available?

Perhaps use Control-Q, which is just next to W in the keyboard:

nmap <C-Q> <C-W>

And you might want to remap the commands that use the same key twice, so in your case use Q twice where there's two W's:

nmap <C-Q> <C-W>
nnoremap <C-Q>q <C-W>w
nnoremap <C-Q>Q <C-W>W
nnoremap <C-Q><C-Q> <C-W><C-W>

Those four there, that would be my recommendation, if Control-W is an inconvenient sequence for you.

Upvotes: 2

Related Questions