![]() ![]() 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! On Macs on iTerm, you can press fn left or fn right to move to the start or end of a command respectively.After years of faithful Vim usage, I've started using Visual Studio Code more and more for my everyday work. In order to delete a line at a time: 0x15 In order to delete a word at a time: 0x17 The difference for these ones is that these aren’t inputtable by keyboard (I think, I mean I could be wrong and you can maybe have a keyboard that sends custom hex codes if you want but you’d be in an uncomfortable minority in that case and why are you reading this?), they’re hex codes: What’s that? I mentioned deleting words as well? Oh right, of course. And the terminal on my up to date Mac doesn’t, so it’s better to be safe than sorry and add this shortcut to iTerm, so it’s available/working everywhere. bashrc or a similar file?), like the one we have at the office, but none other that I’ve SSH’d to has. Note: To be honest, some servers do this by default (I assume by editing. With that knowledge, you can go ahead and add that to your iTerm shortcuts for the uncunning, there’s a screenshot of dubious usefulness as the featured image of this post. In order to move backwards a word at a time, you need to press ESC b In order to move forwards a word at a time, you need to press ESC f (*Insert Jackie Chan WTF face here*) However, while you’d expect that by 2017 it’d be smart enough to use the current keyboard shortcuts that are used everywhere else by default, it’s not smart enough to use the current keyboard shortcuts that are used everywhere else by default. ![]() Miraculously (or through the hard work of people who thought a lot about things in the past) bash has the integrated ability to move word by word, delete word by word or line by line, and move to the beginning and end of a line, much like on any other text editor. If you’re here you’re probably computer savvy enough to adapt the instructions to your terminal tool of choice. Copper’s Tips
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |