Sahat Yalkabov
Sahat Yalkabov

Reputation: 33674

How do I press "<C-L> <C-W>l<C-W>_" in Vim?

In one of the vim config files I have noticed this keyboard mapping map <C-L> <C-W>l<C-W>_ supposedly for easier moving in tabs and windows. What does that translate to keyboard presses? What is that underscore at the end for?

Upvotes: 4

Views: 1291

Answers (2)

romainl
romainl

Reputation: 196731

The Ctrl+wlCtrl+w_ keys sequence is somewhat too long so someone has created a shortcut ("mapping" in Vim-speak): Ctrl+L for it.

<C-w>l<C-w>_ moves the the cursor to the window on the right (<C-w>l) and maximizes it vertically (<C-w>_).

Mappings always follow the same structure:

  1. map (or imap for insert mode mapping, nmap for normal mode mapping, etc.)

  2. some whitespace

  3. the shortcut you want, here <C-L>

  4. some whitespace

  5. the sequence of commands triggered by the shortcut

See :help windows for more info on window management and :help mapping for more info on mappings.

Upvotes: 3

David Brown
David Brown

Reputation: 13526

The command map <C-L> <C-W>l<C-W>_ maps Ctrl-L to Ctrl-W, l, Ctrl-W, _.

You invoke this binding by just pressing Ctrl-L. To invoke what it binds to you would type Ctrl-W, then l, followed by Ctrl-W again, and finally _ (which on a US keyboard is shift-hyphen). This is two separate bindings, <C-W>l moves the cursor to the window to the right, and <C-W>_ resizes current window to the maximum possible vertical size.

Upvotes: 6

Related Questions