AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Emacs vim shortcuts7/30/2023 It is rarely efficient to use the fundamental movement keys if you are moving the point more than a few characters. To move to the beginning of a line, type C-a to move to the end, type C-e. The move to beginning and end of line commands bear mentioning as well, as they are also a crucial part of movement. Useful, as it means you won’t have to reach for the return key to add newlines! ( setq next-line-add-newlines t) emacs, as it makes C-n insert newlines if the point is at the end of the buffer. The four fundamental movement keys are C-n, for next logical line C-p, for previous logical line C-f for move forward by character and C-b for move backward by character. ![]() A good Emacs hacker constantly moves and edits, and in rapid succession: it is folly to stop, start, stop, start every time you navigate the buffer. Every time you take your hand off the “home row” to use the navigation keys you are wasting time – time that adds up, considering how often you move around in code or text. If you’re an experienced Emacs user, all of this should be muscle memory by now, but I have to start somewhere and the beginning is the best place.Įmacs does support the navigation keys (arrow keys and pg up/down and so on) but it’s better to learn the real Emacs keys. Not all commands have an inverse, or they do unexpected things – particularly if it is a third-party command – but almost all the keys I’ll be talking about in this series will work with a negative argument. If you want to capitalize the last word you just typed, type M- M-c. Negative arguments are very useful, for they can let you operate on words, lines or phrases you have just finished typing. It is bound to M- (that’s meta followed by a dash) C- and C-M. Like numeric arguments, the negative argument is bound to multiple keys to minimize unnecessary finger movement. When used with the numeric argument, the negative argument inverts the operation the command would otherwise carry out. Odd or hard to reach keys are used less – empirically, it is not a difficult conclusion to reach. Simple things like duplicate keybindings cut down on finger-straining typing and it increases the likelihood of people actually using numeric arguments in the first place. So to run the command forward-word, bound to M-f, 10 times you’d type M-1 M-0 M-f. īy duplicating the same command multiple times, you don’t have to move your fingers to execute a command that uses C-, M- or C-M. Most commands do what you would expect.īecause numeric arguments are so useful they are bound to a multitude of keys: M-0 to M-9 C-0 to C-9 C-M-0 to C-M-9 and C-u. For C-p it moves up n lines, for other commands it does nothing. What the number is for used for depends entirely on the command you use it on. The numeric argument is so called because it lets you pass a numeric constant to a command. The universal argument (also known as prefix argument) is multiplicative when invoked repeatedly. This concept deserves a mention as it will invoke an extended, and typically more complex, version of a command or it will default to the numeric argument 4, meaning it essentially does the same as though you had typed C-u 4. You may not want to use all of them – which is fine – but I will try to highlight the importance of switching or changing something to give you an idea of how much of an improvement it is. Included in this series will be code snippets, suggestions for rebinding keys and other tips and tricks I’ve picked up over the years. I’ve been using Emacs for a long time and I still learn new ways of doing things faster but ultimately it is tenacity and persistence that will pay off in the long run. Editing text effectively can take a while to learn, as there are many specialized tools available to you to make your life easier. The best way to maximize your productivity is to eliminate common bottlenecks like learning how to touch type and, of course, mastering Emacs. But old habits die hard, and when your IDE’s most advanced text editing capability is a poorly-emulated Brief mode it’s no wonder people can’t be bothered. I’ve met lots of IDE users who use the mouse to edit text or access menu options, even though – and they realize this – it is very ineffective. OverviewĮmacs has grown organically – some might say uncontrollably like kudzu – over its more than 40 year history, and in that time it has been honed and sharpened as a tool for effective text and source code editing. Few other things in Emacs will, pound-for-pound, give you a bigger productivity boost. ![]() Emacs has unrivaled movement and editing capabilities. ![]() If you can master movement and editing in Emacs, you have effectively conquered two of the biggest productivity boosters available to you.
0 Comments
Read More
Leave a Reply. |