qvacua / vimr

VimR — Neovim GUI for macOS in Swift
https://twitter.com/VimRefined
MIT License
6.63k stars 218 forks source link

Switch tabs using <⌘-1>, <⌘-2>, etc. #537

Open pjg opened 6 years ago

pjg commented 6 years ago

It would be awesome if we could switch VimR tabs using ⌘-<number>, just like it happens in Chrome/Firefox/iTerm and probably a bunch of other apps.

What do you think?

askedrelic commented 6 years ago

This already works with normal gvim bindings: https://github.com/askedrelic/dotfiles/blob/4e153e51a8e7421f7b6cc5466398f46e1a9b57d0/.vimrc#L913

pjg commented 6 years ago

Thanks! That's one impressive .vimrc. However, in VimR ⌘+1 is mapped the hard way to toggle "File Browser" 😢

Any way to turn it off?

qvacua commented 6 years ago

This is related to #418... Maybe we should do it like the IdeaVim plugin for JetBrains IDEs...

askedrelic commented 6 years ago

@pjg you can turn off the File Browser in the Preferences > Tools menu. I turn off all the tools, then all Apple+# keys work!

pjg commented 6 years ago

@askedrelic thanks, this worked!

Tehnix commented 6 years ago

Alternatively, you can remap the File Browser, as you can with any macOS app (instead of turning it off).

  1. Go to System Preferences -> Keyboard -> Shortcuts,
  2. choose App Shortcuts,
  3. add (with the +) a new shortcut
  4. Configure it to: a. set the Application to VimR.app, b. set the Menu Title to Toggle File Browser c. set the Keyboard Shortcut to whatever you want (I use Shift+Cmd+E to mimic VSCode)

It'll look something like,

screenshot 2018-03-12 12 32 33

In my vim configuration I have,

    " Switch tab with Cmd + [1-9].
    nnoremap <d-1> :tabn 1<CR>
    nnoremap <d-2> :tabn 2<CR>
    nnoremap <d-3> :tabn 3<CR>
    nnoremap <d-4> :tabn 4<CR>
    nnoremap <d-5> :tabn 5<CR>
    nnoremap <d-6> :tabn 6<CR>
    nnoremap <d-7> :tabn 7<CR>
    nnoremap <d-8> :tabn 8<CR>
    nnoremap <d-9> :tabn 9<CR>
    nnoremap <d-9> :tabn 0<CR>
    inoremap <d-1> <C-o>:tabn 1<CR>
    inoremap <d-2> <C-o>:tabn 2<CR>
    inoremap <d-3> <C-o>:tabn 3<CR>
    inoremap <d-4> <C-o>:tabn 4<CR>
    inoremap <d-5> <C-o>:tabn 5<CR>
    inoremap <d-6> <C-o>:tabn 6<CR>
    inoremap <d-7> <C-o>:tabn 7<CR>
    inoremap <d-8> <C-o>:tabn 8<CR>
    inoremap <d-9> <C-o>:tabn 9<CR>
    inoremap <d-9> <C-o>:tabn 0<CR>

and some additional nice ones are,

  " Save file with CMD+s.
  nnoremap <d-s> :w<CR>
  inoremap <d-s> <C-o>:w<CR>
  " Close current buffer/file with Cmd + w.
  nnoremap <d-w> :tabclose<CR>
  inoremap <d-w> <C-o>:tabclose<CR>
  " Map CMD+z and CMD+Shift+z to undo/redo.
  nnoremap <C-z> u
  inoremap <C-z> <C-o>u
  nnoremap <C-S-z> <C-r>
  inoremap <C-S-z> <C-o><C-r>
  " Map CMD+p to CtrlP.
  nnoremap <d-p> :CtrlP<CR>
  inoremap <d-p> <C-o>:CtrlP<CR>
Tehnix commented 6 years ago

If you want, I could add this to the wiki?

qvacua commented 6 years ago

Feel free to do it. I hope that at some point I can implement a real keyboard shortcut management....