9 ms·
> Electric indent wtf is electric indent? (i'll ddg for it after i write this comment) i've been trying to migrate my coding to emacs for 5+ years (off/on...
by tossAfterUsing 7y ago
> Electric indent
wtf is electric indent? (i'll ddg for it after i write this comment)
i've been trying to migrate my coding to emacs for 5+ years (off/on... obv) and continuously find myself back in Sublime/Atom/VSCode land.
as a user for 24 years, could you maybe point some of us lowly noobs to great resources to learn about Emacs workflow?
TIA
- bitwize 7y agoIn Emacs buzzwordology, "electric" means roughly "computer-assisted". When you hit TAB in Emacs, it will automatically indent your cursor to the proper column, depending on the current major mode (programming language, as determined by Emacs) and indent style. If you do this at the beginning of a line (anywhere before the first non-whitespace character), it will move the whole line to the appropriate position. It's exceedingly convenient, and beats the pants off any IDE that isn't Emacs or something attempting to closely emulate Emacs behavior. As for learning resources, one of the most comprehensive and convenient ones out there is -- Emacs itself! There are reasons why they call it a "self-documenting editor". Boot up the editor, and type C-h t (that is type Control+h, then type t), and you will be taken to a tutorial which you can work through to give you a feel for Emacs basics. While using the editor itself you have a number of help resources available: C-h k followed by another keystroke will tell you what that keystroke does. Type C-h w and enter a function name, and Emacs will show you the keystroke for that function (if any). C-h f and C-h v followed by a function or variable name, respectively, will bring up detailed documentation about that function or variable. C-h i brings up info, which has online user manuals for Emacs and other GNU software (depending on your distribution and installed packages). And so forth. Outside Emacs itself, there is the venerable Emacs Wiki: https://www.emacswiki.org https://www.emacswiki.org -- which covers Emacs itself as well as various third-party extensions and packages for the editor, and contains additional links to other resources. One more thing: If you're serious about learning Emacs, I recommend that you really commit to spending all of your coding time inside it. Don't wuss out and go back to your nice safe comfortable editor when the going gets tough. The best way to learn, when it comes to a program like this, is by doing. If you do wuss out, that's okay too -- not everybody is willing to put in the time it takes to reap the rewards Emacs has to offer, and if they're making good money with the tools they have there's no shame in that.
- yellowapple 7y agoBasically autoindent on steroids. As one example of its niceties: if you select all text (Ctrl-X, then H; "C-x h" in Emacsese) and press Tab, it'll automatically indent the entire file (and likewise, if you select a specific region of text and press Tab, it'll auto-indent that region). It'll also auto-indent as you move to new lines (like any editor's auto-indent does, but Emacs does it a bit smarter). Also, if you press Tab mid-line, it'll indent that line (instead of sticking a tab in the middle of the line, which is usually not what you want). For most languages, said indentation is consistent with (if not exactly complaint with) a style guide or other set of conventions. Some packages customize/alter this (for example, I use the editorconfig package to set indentation sizes and whether to use spaces/tabs by file extension, and electric indent works perfectly with those settings). Unrelated to electric indent (but something I use in conjunction with it daily) is the ability to select a region of text and press Alt-Q ("M-q" in Emacsese) to automatically hard-wrap a long line to 80 characters. Not all languages play nicely with this, but it's really handy for comments, long arrays, and paragraphs in READMEs and other docs.
- yellowapple 7y agoToo late to edit: s/complaint/compliant/