krotdan.blogg.se

Mapping the mac delete key in vim
Mapping the mac delete key in vim








mapping the mac delete key in vim

This means that your goal is simply not worth the hassle.If you do :help key-notation in vim, you'll see that the only modifiers Vim recognizes are shift, control, alt/meta (treated as synonyms), and the Mac command key. Vim is internally consistent and that's what makes it valuable. While it is relatively easy to make the MacVim GUI behave like standard Cocoa text editors, it is virtually impossible to reach that goal with CLI Vim.įurthermore, Vim's command language being vastly more expressive than any "native" set of shortcuts makes it actually counter-productive to try to make it adhere to your platform's limited conventions. Some things will work directly in Vim, some things will require you to create shortcuts directly in your terminal emulator, some things won't ever work.Īdditionally, CLI Vim can't register multiple modifiers at all. The Alt key is usable but not very dependable.

mapping the mac delete key in vim

The Cmd key is only visible to the MacVim GUI so you won't be able to use it in CLI Vim at all. Once again, custom mappings to the rescue: nnoremap v0

#MAPPING THE MAC DELETE KEY IN VIM MAC OS X#

The original Mac OS X behavior has always been a bit complex and non-deterministic, though, so I think you will need a bit of vimscript to reach your goal.Ĭmd-Up and Cmd-Down already do what you want but Shift-Cmd-Up and Shift-Cmd-Down don't do anything. Opt-Up and Opt-down are mapped to by default, not k0 or k$. You can remap them to do whatever you want: inoremap g0Īlt-Backspace already works the way you want but you will need another mapping for Cmd-Backspace: inoremap dg0įn-Alt-Backspace could be approximated with this mapping: inoremap dwĪs far as I know, Fn-Cmd-Backspace has never done anything in Cocoa widgets (I am a bit behind, though) but you could create a Vim mapping if you really want: inoremap dg$ Opt-Left and Opt-Right already do what you want by default, as well as Alt-Backspace.Ĭmd-Left and Cmd-Right are mapped to and by default. Note: MacVim specific answers are okay, but I do use Vim in the terminal a lot as well. (Note: While writing this question I discovered that in Vim, the shift key modifies left or right arrow key presses the way that the option key does in Mac text fields.) How can I emulate these behaviors in Vim, for insert mode only? Shift can be combined with any of these motions to highlight text. In usual text documents this is considered moving to the start or end of a paragraph.Ĭommand up goes to the beginning of the entire text document, and Command down goes to the very end of the entire text document. In other words they align to k0 and j$ in Vim. Option up and down work on actual lines, irrespective of the soft-wrapping positions, and additionally move to the start or end of the line moved to, respectively. (The delete key on the Mac is what PCs call backspace Fn-delete on a Mac means to delete forward one character.) Adding the Fn key as well means deleting to the end of the word or soft-wrapped line. Option or Command delete will delete to the beginning of the word or soft-wrapped line, respectively. Specifically, for those unfamiliar with a Mac:Ĭommand-left moves to the soft wrapped beginning of the line (akin to g0 in Vim).Ĭommand-right moves to the soft-wrapped end of the line, after the space (since soft-wrapped lines are broken between words in Mac text boxes).

mapping the mac delete key in vim mapping the mac delete key in vim

I find these binding extremely intuitive for writing text (whereas Vim bindings are better focused on editing text.) I mostly use Vim (or MacVim) to edit text, but occasionally (such as in writing this question), I use the Mac OS text editing keybindings built in to all text entry fields accessed through a Mac.










Mapping the mac delete key in vim