简体   繁体   中英

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 <CW> <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)?

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.

Vim 仿真设置的屏幕截图

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM