Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I map Ctrl-W to close the current editor tab when using IdeaVim + IntelliJ IDEA?

I want Ctrl-W to close the current editor tab in IntelliJ IDEA. I use IdeaVim, and somehow that seems to be thwarting my attempts.

Things I've tried that didn't work:

  • Adding a "Ctrl+W" shortcut to Settings → Keymap → Main menu → Window → Editor Tabs → Close. This does work if I disable IdeaVim.
  • Adding a "Ctrl+W" shortcut to Settings → Keymap → Plugins → IdeaVim → Close current window. This doesn't seem to do anything at all!?
  • :nmap <C-W> <C-F4> (the default shortcut of Ctrl-F4 does what I want -- I just want Ctrl-W to do it)

I've also tried using the normal vim key of "Ctrl-W c", but this closes all editor tabs, not just the current one.

IdeaVim also doesn't seem to know either :wincmd or :tabclose.

Is there any way to set Ctrl-W as a shortcut for closing the current editor tab while IdeaVim is active (ideally in normal mode, but all modes would be fine too)?

like image 584
Laurence Gonsalves Avatar asked Mar 27 '18 17:03

Laurence Gonsalves


1 Answers

I'm using Android Studio, which is built on IntelliJ, and this works for me:

Go to Settings → Other Settings → Vim Emulation, then change the Ctrl+W shortcut to be handled by IDE.

Screenshot of Vim Emulation settings

You probably also need to add the Ctrl+W shortcut to Settings → Keymap → Main menu → Window → Editor Tabs → Close. But you said that you have already done it.

like image 157
Matias Kinnunen Avatar answered Oct 03 '22 07:10

Matias Kinnunen