0

I often find myself using the following no matter what the program is:

  • Cmd s to save.
  • Cmd a to select-all
  • Cmd t to open a new tab
  • Cmd c to copy
  • Cmd v to paste
  • Cmd z to undo
  • Cmd Shift z to redo

That how it works in most computers, regardless of what mode I'm in or whatever. What would be a good keyboard mapping I can use in vim to do something similar? I don't believe cmd is supposed (without doing some odd mapping).

I also am not a big fan of using ctrl as I often use that in other programs to advance to the start of a line ctrl a or advance to the end of the line ctrl e, and I'm already familiar with ctrl v for visual mode.

What might be a good mapping where I can do something that might feel close to doing the cmd-letter input, i.e. and it will work across all modes (that is, I should be able to select-all whether I'm in normal mode or insert mode)? Additionally, if useful, I'm using vim on mac and (mainly) ubuntu.

3
  • Are you using vim as a GUI (i.e. MacVim or another GVim) or in the terminal? It's easy to write mappings for all these in a GUI version of Vim, but much harder in a terminal as they typically don't pass them through... If you use it in a terminal, what terminal emulator do you use (iTerm2, Terminal.app, etc.)?
    – filbranden
    Commented Apr 15, 2020 at 12:29
  • This question had 3 close votes for being opinion-based. Is it because the OP said "What might be a good mapping..."? Would the question have been received better if the OP had simply said "How can I..."? Commented Apr 18, 2020 at 18:33
  • For future reference, Vim questions can be asked on vi.stackexchange.com. Commented Apr 18, 2020 at 18:34

1 Answer 1

1

I would suggest installing MacVim which already comes with many (all?) of these keybindings set as default.

Within MacVim, I found I could use <D-key> in mappings, to capture Cmd-key presses.

For example:

# Undo and redo
nnoremap <D-Z> u
nnoremap <D-S-Z> <C-R>
# Navigate back and forwards
nnoremap <D-[> <C-O>
nnoremap <D-]> <C-I>

I don't know if these will work for vim in a terminal. They might.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.