This is purely applicable to the Mac version – not sure if this is the right forum for it, but please move it to the correct one if it’s not.
Now and then people express the desire for Vim keybindings to function in Scrivener’s editor, and I’m one of those people… I understand why they’re not included, of course, but I still miss them when editing large amounts of text. I know we can use the built-in Emacs bindings (ctl-A, E, K, N, P etc) which helps a little, but the default bindings for back and forward word with and without select are as bad as using the arrow keys, which is what we’re trying to avoid in the first place.
Anyway, I’ve recently come across a method of creating custom keybindings to be read by any OS X text field (I think), so it works well in Scrivener. It’s a little geeky, so it’s quite possible that everybody who’s geeky enough to want vim bindings already knows about this, but I thought I’d mention it anyway, just it case it helps somebody.
Basically, you create your own file DefaultKeyBinding.dict in a folder KeyBindings inside ~/Library, add your chosen mappings, then restart the application you want to use the new bindings with.
Obviously you can’t emulate Vim’s modal editing, but you can use a single modifier to get most of the more common movement commands. I’ve chosen to put them on the opt / alt key, because I only ever use the opt key for modifying vowels. Therefore I can use opt-h/j/k/l for single movements, opt-w/b for word movements, opt-g for beginning of file etc. Add shift to these bindings and they select the text as well. I’ve also added ctl-f/b for page down/up. Obviously, you can’t make every binding an exact analogue of the vim version (you don’t seem to be able to replicate gg, so I use opt-g for beginning of file and ctl-g for end, for example) but you can get quite close… You can also use the same file to add shortcuts for common symbols such as ∵ and ∴.
Here’s my current version of the file. ~ = opt key, ^ = ctl, @ = cmd. Upper case letters are obviously those with Shift applied.
[code]{
/* vim arrows */
“~h” = “moveBackward:”;
“~H” = “moveBackwardAndModifySelection:”;
“~l” = “moveForward:”;
“~L” = “moveForwardAndModifySelection:”;
“~k” = “moveUp:”;
“~K” = “moveUpAndModifySelection:”;
“~j” = “moveDown:”;
“~J” = “moveDownAndModifySelection:”;
// Page
“^b” = “pageUp:”;
“^B” = “pageUpAndModifySelection:”;
“^f” = “pageDown:”;
“^F” = “pageDownAndModifySelection:”;
// Word
“~w” = “moveWordForward:”;
“~W” = “moveWordForwardAndModifySelection:”;
“~b” = “moveWordBackward:”;
“~B” = “moveWordBackwardAndModifySelection:”;
“~g” = “moveToBeginningOfDocument:”;
“~G” = “moveToBeginningOfDocumentAndModifySelection:”;
“^g” = “moveToEndOfDocument:”;
“^G” = “moveToEndOfDocumentAndModifySelection:”;
// Paragraph
“@~j” = (moveToEndOfParagraph:, moveDown:);
“@~J” = (moveToEndOfParagraphAndModifySelection:, moveDownAndModifySelection:);
“@~k” = (moveToBeginningOfParagraph:, moveUp:);
“@~K” = (moveToBeginningOfParagraphAndModifySelection:, moveUpAndModifySelection:);
“~p” = “selectParagraph:”;
// Misc
“~1” = (“insertText:”, “\U2234”);
“~9” = (“insertText:”, “\U2235”);
// move line Up
“^@\uf700” = (selectParagraph:, setMark:, deleteToMark:, moveLeft:, moveToBeginningOfParagraph:, yank:, moveLeft:, selectToMark:, moveLeft:);
“^@k” = (selectParagraph:, setMark:, deleteToMark:, moveLeft:, moveToBeginningOfParagraph:, yank:, moveLeft:, selectToMark:, moveLeft:);
// move line Down
“^@\UF701” = (selectParagraph:, setMark:, deleteToMark:, moveToEndOfParagraph:, moveRight:, setMark:, yank:, moveLeft:, selectToMark:);
“^@j” = (selectParagraph:, setMark:, deleteToMark:, moveToEndOfParagraph:, moveRight:, setMark:, yank:, moveLeft:, selectToMark:);
}[/code]
The actual commands (selectParagraph etc) are OS X’s own functions, of course. NB: the file is quite fragile — a single error in the format breaks it, so you need to check it carefully, but once you’ve got it working you don’t need to change the file again.
A detailed treatment of what’s possible can be found here: http://osxnotes.net/keybindings.html
I’ve only started to skim the surface of this, and no doubt I’ll modify it over time. It’s by no means a complete solution, but I’m finding it useful, so I wondered if others would too… Apologies for the length of the post, but fortunately, this hack works for Safari text boxes too, so I could use vim bindings…