Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 551
Sahat Yalkabov Avatar asked Nov 15 '25 20:11

Sahat Yalkabov


2 Answers

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.

like image 51
David Brown Avatar answered Nov 17 '25 12:11

David Brown


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.

like image 36
romainl Avatar answered Nov 17 '25 12:11

romainl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!