![]() ![]() ![]() Sadly, there's no hex representation for the command key, so this doesn't help us with our original problem. So, to emulate Ctrl-P via a hex code, we'd map ⌘P to 0x10. For that, we'd have to use a program like xxd to inspect the hex codes for different keys on the keyboard. Unlike the Vim bindings, though, it can be difficult see at-a-glance how we'd adapt this to other keys. This approach involves asking iTerm to sending the hex codes for a different pair of keys to the shell, as if we'd hit those buttons on the keyboard instead. (That's actually how I stumbled upon the "Vim Special Characters" option!) While I was researching how to do this, I came across this StackOverflow answer which suggested using the "Send Hex Code" action. Don't forget the leading backslash – otherwise it'll just print literally.Īnd that's it! When you press ⌘P, iTerm will now interpret it as Ctrl-P. Then, simply type the Vim binding you want to map this key to, like \ or \. Then, choose the "Send Text with 'Vim' Special Characters" option from the "Action" dropdown. Click the " " button to add a new mapping:Ĭlick the box next to "Keyboard Shortcut" and then press ⌘P – you should see it appear in the box. Open Preferences and head to Profiles → Keys. ITerm allows us to add custom key bindings in our profile. The best we can do is tell iTerm, a modern graphical application, to intercept our ⌘P keystroke and turn it into another key combination that the terminal can understand, like Ctrl-P. " This removes the Cmd-P binding from 'Print':Īlas, the terminal doesn't know about the Command key and so that doesn't help us when using classic Vim. And that's where that newly acquired muscle memory betrayed me – as all my attempts to quickly open files ended up mired in iTerm's "Print" dialogue! No good! Re-mapping ⌘P to Ctrl-P in MacVimĪccording to the Vim documentation, you can theoretically map the "command" key using the :CtrlP map :CtrlP " In ~/.gvimrc: if has( 'gui_macvim') However, I still use Vim to make quick edits to files here and there. It took a long while to rebuild my Ctrl-P muscle memory to ⌘P, but I finally did it! Your command line navigation will now be faster and more precise.After years of faithful Vim usage, I've started using Visual Studio Code more and more for my everyday work. The cursor will now “jump” over entire words as it does on other applications. Click “OK”.Ĭlose the menu and begin using the Alt and the left/right arrows immediately. ![]() This time, in the “Esc ” field, type lowercase “f”. Open the same context menu for Alt plus right ⌥→ and again change the action to “Send Escape Sequence”. In the “Esc ” field, type lowercase “b” and click “OK”. Double click it.Ĭhange the action from “Send Hex Code” to “Send Escape Sequence” (you might have to scroll a bit to find this). Within the “Key Mappings” pane, find the mapping for the Alt and left keys, which will look like this: ⌥←. Open the “Preferences” menu: either find it in the “iTerm2” dropdown menu along the top of the screen or press the Cmd and comma keys. Note: I refer to the “Alt” key throughout this post, which is the text written on my old 2013 MacBook Pro keyboard, but this is normally called the “Option” key in MacOS. With a little config, you can change this behaviour, which I’ll explain below. However, on first install, you can’t use the Option or Alt key (this key: ⌥) as you would in other applications: you can’t skip or jump over words by pressing Alt and the left or right keys. It has many more handy features than Terminal, is free to download and is also open source ?. ITerm2 is a replacement for the default Terminal application on MacOS.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |