17 ms·
My Emacs Productivity Tricks/Hacks
- 098799 7y agoHelm-projectile rant is well deserved. I'm often ashamed looking at my colleagues trying to find some file with a mouse in their big fat IDEs.
- mycpuorg 7y agoMortals. LOL!
- elcomet 7y agoAll decent IDEs have a file search command.
- wry_discontent 7y agoI like Emacs a lot, but it' definitely lacking most of the advanced IDE features, and the Emacs features that a decent IDE (read: Intellij) implement are usually "good enough" for me. People who've been using only Emacs for the last 20 years are in no position to comment on IDEs
- smabie 7y agoWith lsp-mode, there’s really nothing I can think of that emacs can’t do compared to IDEs. In fact, emacs blows them out of the water. Before LSP was invented, I would have agreed with you. But pretty much all IDE features have been commoditized by LSP now.
- iudqnolq 7y agoI only know about the example of Rust, where IntelliJ is still significantly better and faster than lsp.
- aasasd 7y agoThe man-or-boy test for IDEs was proposed long ago by Martin Fowler. If the editor can do the ‘extract method’ refactoring, then it's an IDE that properly understands the structure of the code. More generally and forgivably, I'd say the IDE must know that two variables of the same name may be different variables, and to know which instances are which vars. Funny enough, this benefit of IDEs might rarely be felt with Javascript due to its uber-dynamic nature (at least without classes).
- skocznymroczny 7y agoAre there any languages other than C#, Java and maybe Dart that have these features? As soon as you add any kind of metaprogramming or macros to the mix, IDEs start to break, because they can't refactor code that doesn't exist yet. That's an issue for IDEs for C, C++, Rust, D and probably few other languages.
- aasasd 7y ago> Are there any languages other than C#, Java and maybe Dart that have these features? If you're talking about ‘extract method’, any regular imperative language in the C style should have that―possibly as ‘extract function’. I mean also Python, JS, Ruby and the like. The hard part here is to figure out which vars go into the method/function and which of them must be accepted as parameters or returned from the function―that's where the understanding of code structure comes in. Sure, fiddling with metaprogramming will break IDE's understanding of the code, e.g. in Python, but you can do that carefully and isolate the effects so that the rest of code is still ‘clean’. That's also why Java integrates any and all features into the type and OOP system (afaik), so the code can always be described statically. I guess Haskell is an extreme example of that, but not sure how IDE-friendly it is.
- dmortin 7y agoI use emacs, but I don't think lsp-mode can do all the refactorings which intellij provides: Safe Delete Extract Method Extract Constant Extract Field Extract Parameter Introduce Variable Rename Inline Change signature Refactorings are great, because you can do safe code transformations very quickly. If you get to know these features, it's hard to do without them.
- iLemming 7y agoEmacs's greatness lies somewhere else. Its extensibility is unmatched. IMO there's no other software product ever been created that can be extended like Emacs. I'm sure if given enough resources and motivation, it's possible to build superb support for the modern programming languages. For example, you wouldn't claim that Intellij/VSCode/Sublime/Atom has better support for Erlang, for OCaml, for Lisp, for LaTeX, would you? Emacs evolves slowly. Things take time. And yes, there are always IDEs that do things [slightly] better. At a given moment. Remember, though Emacs outlived many trendy IDEs. Relatively not too long ago IDEs like C++ Builder and Delphi Builder, Eclipse, NetBeans were quite popular. And they did have some remarkable features that Emacs didn't. Do you see any HN posts about those anymore? Now check, for example, Github Language Stats¹ and find there emacs-lisp. Isn't it surprising to see it somewhere in the middle of the list? Isn't it surprising that it made into that list at all? Remember that it is not a general-purpose language; it is not used in the enterprise; it is not used in the game industry; not suitable for writing mobile apps or web pages. And it also a pretty concise language, it's a Lisp. But there's a lot of it on GitHub alone. Who are these people? Who writes all that code? And how the heck they keep doing it - none of them ever have gotten paid for it, aside from some tiny voluntary contributions and hugely successful Kickstarter campaign for Magit. If a programming language stays relevant for long enough, people eventually will build emacs packages for it, and they'll keep improving them. But for a proprietary IDE, if it doesn't have a feature you like - you have no other option but to submit a request and wait. Sometimes you have to wait indefinitely. > People who've been using only Emacs for the last 20 years are in no position to comment on IDEs I moved to Emacs after almost 20 years of using IDEs. If I am still programming 20 years from now, I'm sure it will be in Emacs. ____ * ¹ https://madnight.github.io/githut https://madnight.github.io/githut
- 098799 7y agoSomehow my colleagues who use VS Code or JetBrains IDEs don't manage to learn about those features while all of my vim-using colleagues somehow do. (Haven't worked with anyone using Emacs yet)
- umanwizard 7y agoI use CLion almost exclusively and I use shift-shift to find things so often that I have basically no idea what file anything is in. Is there anything free that even begins to approach the quality and accuracy of the JetBrains Rust analysis plugin? If so, I’d love to know about it and start using vim.
- stjohnswarts 7y agoI'm sure there has to be a vim plugin for rls
- umanwizard 7y agoYes, there is. But RLS is much worse than the CLion Rust plugin, in my experience.
- ainiriand 7y agoIn JetBrains you just double shift and a small searchbar opens to allow you to type in any file name. It autocompletes so you do not have to remember the whole name. It is pretty neat.
- umanwizard 7y agoNot just any file name, but any symbol.
- iLemming 7y ago> All decent IDEs have a file search command. Yes, all decent IDEs have file search command. But Emacs got SEARCH: - You can search for all files that contain given string and then open the search results and modify occurrences using multiple cursors and then save it, and it will propagate changes in multiple files; - You can recursively search for file names, then (for example) mark those that are bigger than 15Mbs, or files that were edited last time in March, and then tell Emacs to show git-log of changes, but only related to those files; - You can search for a pattern, but also tell it to display it with a context (for example 4 lines before and after the occurrence); - You can recursively search for a filename pattern, and then among those that you find, you can rename those that match a regexp; - You can git-grep for a file that was deleted in the repo; - You can find all the compilation/linting errors and warnings in the code for a given project; And guess what? All that works the same way for remote machines. You can use the search on a remote computer and open files, just like it was a local machine. Heck, you can even search and open files inside Docker containers. You think I'm done here? I haven't even talked about searching for stuff using Org-mode. Seriously, whenever there's an argument about IDEs vs. Emacs - Emacs just beats the shit out of any. "But it doesn't support re-factoring... bleh-bleh." Like everyone who seriously uses Emacs really doing it because they hate refactoring or something. Emacs has better tools and a myriad of ways to deal with code.
- molteanu 7y agoWell, not if they use Notepad.
- bentcorner 7y agoIs there anything like vs-chromium's code search in emacs? After finding vs-chromium I lean on it so hard that when I tried to switch to emacs, helm-projectile was good but wasn't good enough. Plus I'm on windows and there was enough friction where things kind of worked but didn't (usually environmental things like it couldn't find ag or awk, process lifetime, window drawing, etc.).
- beizhia 7y agoNot sure how vs-chromium's search is, but I use helm-projectile-rg for searching, and it's pretty nice (and super fast)
- hellofunk 7y agothe others I cannot live without: neo tree winner mode god mode (I use instead of evil mode) avy (visually jump to any char on the screen) undo-tree (really neat, though I don't use it as much any more)
- tptacek 7y agowinner-mode was new to me. Thanks! The most annoying thing about Emacs for me is random windows popping up; I'm a "separate frames" person (the OS window manager does fine for me, I don't need much help from Emacs), and anything that streamlines windows is great.
- mycpuorg 7y agoI have tried neo-tree and undo-tree. But never really got around to using them well. Maybe, I need to be patient.
- NotATroll 7y agoI find undo-tree to be super useful in rare occasions, thanks to undo-tree-visualizer-toggle-diff bound on d. The quick diffs can be pretty darn helpful with complex changes.
- tmsh 7y agoNeo tree was annoying to me (coming from NERDTree). I remapped things to work like NERDTree ('l' for open? should be o!). And then I finally grokked how much simpler it was to navigate directories with hjkl. Plus ? to see how to manipulate files and just keep it there is great. Way more ergonomic than NERDTree or Treemacs imho. Also since I'm going on here, I've found the key to editor management is to make sure certain basics work across the board (for IntelliJ/, Xcode/Xvim, (space)emacs and even vim - sometimes I use vim for config changes since it's so fast to open, tmux, etc). C-o/C-i -> should work for navigation ctrl-shift-j -> should select the file you're working on ; -> should map to : (retrain yourself) fd -> escape (retrain yourself) c-hjkl -> c-w hjkl (faster window/panel navigation) gd -> should go to definition vim text motion in general should work flawlessly e.g., @q - should start to record a macro I use spacemacs + tmux since I like to customize and it's easiest to customize in elisp I've found than in any other IDE or vim itself. And when things don't work and I can't make it work in the editor itself, I fix it in the terminal app (Kitty) or the OS (BetterTouchTool). Shameless plug for those curious: https://github.com/p10q/home/blob/master/.spacemacs#L343 https://github.com/p10q/home/blob/master/.spacemacs#L343 https://github.com/p10q/home/blob/master/kitty.conf#L797 https://github.com/p10q/home/blob/master/kitty.conf#L797
- kwindla 7y agoalso tramp, for editing files on any machine you can ssh into ... https://www.emacswiki.org/emacs/TrampMode https://www.emacswiki.org/emacs/TrampMode
- mycpuorg 7y ago<Same response as org-mode> A resounding YES! But Org-Mode and TRAMP are so well written about that although I have "special" setup for these in my config I felt I could not do more justice than other expert write-ups. Maybe, I should add them in a separate entry.
- arendtio 7y agoNow I understand why the saying goes like: Emacs is a good OS... ;-)
- usr1106 7y agoI used TRAMP a lot in the past, for some reason I have mostly forgotten about it. Maybe my projects just changed in nature? Thinking of it, what I do rather frequently is ssh into a server and sudo -e there (root account is locked). I'm somewhat confident that TRAMP can be configured to do that. Need to investigate when I have time.
- tretiy3 7y agoI am using tramp primarily to edit files inside docker containers. https://github.com/emacs-pe/docker-tramp.el https://github.com/emacs-pe/docker-tramp.el
- kleer001 7y agoorg f-ing mode edit: actual package is called "org-mode"
- mycpuorg 7y agoA resounding YES! But Org-Mode and TRAMP are so well written about that although I have "special" setup for these in my config I felt I could not do more justice than other expert write-ups. Maybe, I should add them in a separate entry.
- smabie 7y agoWhat's the point of TRAMP when you can just use the FUSE sshfs module?
- julienchastang 7y agoCan you compare and contrast the two? I really like tramp for seamlessly editing files on a number of remote VMs. You can even edit files inside Docker containers on remote systems via multi-hops. Tramp is a huge timesaver.
- orangse 7y agoWell one major thing is that tramp is inside emacs so you can configure it with elisp, which is a major plus in my mind. The main problem with tramp is that Emacs is single threaded (and elisp threads run one at a time), so networking operations can be iffy. On most normal connections it works fine in my experience. Another reason to use sshfs is if you're switching between Emacs and a separate terminal, you don't need another connection. That goes away with vterm since now you don't need a separate terminal (it fixes a lot of the traditional problems with ansi-term, shell-mode, and eshell. Although there's a good argument to make for using eshell as your main shell).
- iudqnolq 7y agoBy vterm do you mean this? https://github.com/akermu/emacs-libvterm/blob/master/README.md https://github.com/akermu/emacs-libvterm/blob/master/README.... It seems extremely experimental, and I've been trying recently to make my emacs more stable so I can choose when I want to spend time editing my config.
- anarchyrucks 7y agoI installed Doom[0] and called it a day! [0] https://github.com/hlissner/doom-emacs https://github.com/hlissner/doom-emacs
- gregf 7y agoI had a fairly large config and kept running into problems with speed. I gave up late last year and tried doom and haven't looked back. Very fast compared to what I had hobbled together.
- komali2 7y agoLooks interesting, but the main page claims it has support for a lot of languages, but according to this module page it only supports javascript, typescript, and html? https://github.com/hlissner/doom-emacs/blob/develop/docs/index.org#lang https://github.com/hlissner/doom-emacs/blob/develop/docs/ind...
- NotATroll 7y agoThe TODO is regarding documentation iirc. All the languages supported are in the init.example.el file seen here: https://github.com/hlissner/doom-emacs/blob/develop/init.example.el#L107-L165 https://github.com/hlissner/doom-emacs/blob/develop/init.exa... Uncomment them, run doom refresh. Check their module under https://github.com/hlissner/doom-emacs/tree/develop/modules/lang https://github.com/hlissner/doom-emacs/tree/develop/modules/... for any external requirements that they need or flags that they support.
- snicker7 7y agoThe comments are hilarious: ;;hy ; readability of scheme w/ speed of python ;;rust ; Fe2O3.unwrap().unwrap().unwrap().unwrap() ;;javascript ; all(hope(abandon(ye(who(enter(here))))))
- rocha 7y agoFrom my experience, most of the packages listed there with TODOs have basic support with some extras, but are lacking documentation and testing. For example rust, supports syntax, formatting, lsp or racer, cargo and other goodies.
- myrloc 7y agouse-package would be an improvement upon most of the code snippets in the blog post. Loading packages without it these days feels like a sin.
- rntksi 7y agoIf the author, @mycpuorg, is reading this comment: please, PLEASE, do write about your mu4e configuration.
- mycpuorg 7y ago@rntski, I will be happy to. I feel I get a bigger bang for buck for Work Email on Outlook Exchange since Email on mu4e makes me less distracted.
- jimmyvalmer 7y agoThis sentence is either missing a negation or correlates "bang" with "distraction", which is wrong since "bang" is positive and "distraction" negative.
- mycpuorg 7y agoYou are right, scratch that and I will try this again. I meant to say: I have configured and used mu4e on a GMail account and another account hosted on Microsoft Exchange Server (MSE). The Linux based email client I had tried before mu4e for MSE account are: * WebMail (Outlook's less capable younger cousin on a browser) * a slew of Linux UI email clients like Thunderbird etc. I disliked all of them equally. However, using mu4e for emails with Outlook/MSE account makes doing emails less painful and less distracting. However, using mu4e as a mail client for Google accounts may not be preferable if you have bought heavily into the Google ecosystem. I have had trouble with things like Google API authentication on Emacs.
- jf 7y agoI've used Emacs for decades and still feel like I'm barely scratching the surface. What would really help me with articles like this one is more narrative on _why_ these particular modes are so useful. For example, it took me a long time to learn org-mode because I just didn't know what to do with it! I feel like Helm is similar, I've tried it briefly, but I'm not sure if or how it would fit into my workflow.
- ashton314 7y agoI completely agree. I used vanilla Emacs for about a decade before finding list-packages. (I know, I know. I was really behind.) But stuff like org-mode never clicked for me. I had to sit down with the manual and read it to finally get a handle on what it is. I'm currently drafting an essay on what makes org-mode compelling, rather than how to use it. I think I'll do the same for other tools I use.
- jf 7y agoAwesome! I love reading essays like what you're planning on writing. Let me know how I can help, for example: I'd be happy to review drafts, be a sounding board, etc - my contact info is in my HN bio. Let me know!
- ashton314 7y ago:) Thanks! I’ll ping you when it’s ready for some feedback.
- BeetleB 7y ago> I used vanilla Emacs for about a decade before finding list-packages. To be fair, list-packages is a relatively recent addition to Emacs (2012).
- cannam 7y ago> I completely agree. I used vanilla Emacs for about a decade before finding list-packages I think it helps to think of Emacs as just another platform - and a nice stable one. You may or may not use, or know about, all the "applications" available for it. New stuff comes along that you haven't heard about; you might occasionally want to review things; and it doesn't really matter if you don't. I've been using it for the usual handful of decades and have gone through phases of using one exciting new thing or another, but I've dropped most of them - I no longer run builds from Emacs (I do recompilation in the background in a separate terminal), nor read mail or use version control software from within it. I don't use evil and my colour scheme is mostly black-on-white. My .emacs has ended up almost back where it was 25 years ago. (In fact it still has references to Epoch and Lucid Emacs in a couple of comments.) The two additions in the past couple of decades that have made a big difference to me are Tramp (a nice upgrade from ange-ftp) and the ability to set non-integer line spacings.
- antoineMoPa 7y agoMy favorite these days is a package called find-file-in-project. Ideal for navigating large projects.
- agumonkey 7y agorelated, projectile-mode gives a bunch of similar niceties
- deleted 7y ago[deleted]
- aptidude187 7y agoI used to think that Emacs is some weird editor with absurd keybindings, until I learned lisp and understood what makes it so special. Now Emacs (Spacemacs[0]) is my main driver. [0] https://www.spacemacs.org https://www.spacemacs.org
- quickpost 7y agoHow did learning lisp help you understand the power of Emacs? Just starting down the Spacemacs road myself (from Sublime Text), and curious to hear more about your experience!
- molteanu 7y agoIn short, you can add new functionality to Emacs yourself. And just like in the world of Lisp, after you add a new functionality, it becomes indistinguishable from what you already have. That is, it looks like it has been there all along, from the start. It doesn't look like a 3rd party plugin that you need to take special precautions to install. It just blends in nicely, and naturally. Or, to put it another way, if you learn (Emacs) Lisp and you start to tweak Emacs to your own liking, you can transform Emacs into your own personal tool, adjusted exactly the way you like it, no questions asked.
- aptidude187 7y agoThank you molteanu for chiming in. I would also add, that everything has the exact same interface, meaning I can access every tool in the same way, the consistency is unparalleled. For example: In VSC when I want to use the shell, I suddenly lose my vim bindings and thus drop down to the casual user mode. In Emacs I can treat the shell like any other buffer, apply all my tools and knowledge, so it's nothing foreign or something that wants to be treated differently. For instance similar point in VSC regarding the file explorer, it forces you to abandon the keyboard homerow, I can't use my vim bindings from the plugin, because the plugin is something 'foreign'. Sure you can memorise shortcuts, but it's not the same as using your vim bindings for everything, always.
- why-el 7y agoAnother beautifully designed piece of Emacs software is magit, where the defaults are extremely sane. The package is self-documented and you can learn it all by typing ? anytime. Being able to git log the file you are in is also a huge plus.
- ninjha01 7y agoMagit made me a better programmer. Learning `git` proper would probably be as good (and certainly get more street cred), but magit was more accessible and more fun to use since I was already emacs-proficient.
- celeritascelery 7y agoThe thing I love about magit is that it taught me git. You can hit $ and see exactly what I’d bring run and many of the options are in the pop up.
- agumonkey 7y agoI'm still not sure there's anything better than magit on the market. People say org is the killer app, but imo it has nothing on magit. (It's a weird comparison Ill give you that) I'm thinking of donating again
- wry_discontent 7y agoThese days, Magit is the only thing I consistently open Emacs for.
- acheron9383 7y agoCan't say enough good things about Magit, it is astounding how much better it is than other version control software built into IDEs. Magit feels like it expands what I can do with git, rather than other IDEs dramatically limit what git can do. For instance interactive rebaseing is so much better in Magit.
- imiric 7y agoFunny, Magit never clicked for me. Maybe because I'm used to the quirks of the Git CLI and have aliases setup that speed up my workflow considerably, I never could reach the same productivity levels with Magit, and I've tried several times over the years. Magit forces certain workflows because the author and community feel those work best, and stepping outside of that is often an exercise in frustration because you're not doing things "the Magit way". After going through a few issues on their tracker it was clear that there's no place for improvement suggestions unless it aligns perfectly with the maintainers' vision. It feels very "holier than thou" and the constant hype around it everywhere is a bit off putting. Maybe it's just me, but I prefer using plain Git in a regular shell (Emacs shells are also unusable for me), with shell and Git aliases, and helper tools like scmpuff[1]. [1]: https://mroth.github.io/scmpuff/ https://mroth.github.io/scmpuff/
- rb808 7y agoIt seems a lot of people have used emacs for years and love it. I never saw the point of learning as it seemed cryptic. In 2020 is it worth putting the effort to learn now? I figure with vim and IDEs I dont really need it.
- fredsir 7y agoI switched to emacs in 2019 after using primarily vim for 12 years, and I think it's more than worth it. It's not an editor, it's not an IDE, it is kind of like an operating system where you can have a text editor, debugger, notes, mail, whatever you want. If you dig that, you'll love emacs. It's extensible in a way you've probably not experienced anywhere else, so if you like honing your tools so they fit the way you want to work, emacs is for you. I've actually come to long for an operating system that gives me the same "interactivity" as emacs does. Of course, I edit text in emacs with evil: https://github.com/emacs-evil/evil https://github.com/emacs-evil/evil
- Koshkin 7y ago> not an editor It's "editing macros," so yes, it's an editor first and foremost. > not an IDE It's integrated; mostly used by developers; it's an environment.
- smabie 7y agoI mean, I play NetHack in it. I don’t think any IDE has that kind of flexibility.
- Koshkin 7y agohttp://eclipse-games.sourceforge.net/ http://eclipse-games.sourceforge.net/
- anthk 7y agoThat's nothing. You can do, in Emacs: - Run Nethack - Chat over IRC. Double combo with Bitlbee - Chat over Slack/$whatever proto is designed in Elisp - Write Interactive Fiction - Emulate Interactive fiction with a Z machine in Elisp - Write and read emails/news with GNUs - Listen to music with EMMS - M-x doctor because is too complex and you need to talk to someone - Comment on HN with eww - Do literate programming - Do math, and with Maxima/R, algebra/statistics/whatever - Use GIT with Magit - org-mode. With this you could write three ebooks larger than the Java specs. - org-babel. I forgot it. This is damn magic. Programming as if you were in a word processor, going back and forth, easily, showing up your results inline.
- cmrdporcupine 7y agoI'm ashamed to say I've been using Emacs since 1992 but I have never been able to impress into my brain anything other than the minimal set of keystrokes to do basic editing. I feel like I need to be trapped on an island where the only thing I could do was learn emacs for a bit. There's so much there to dig into.
- pmoriarty 7y agoThis is why I regularly create hydras for every emacs mode that I use. That way I don't have to remember any extra keystrokes, as the hydras will remind me.
- cannam 7y agoWhat's a hydra? (in this context)
- NateEag 7y agoA cluster of Emacs keybindings that share a common prefix, implemented using the hydra library: https://github.com/abo-abo/hydra https://github.com/abo-abo/hydra
- cannam 7y agoSo it's sort of like a mode switch? You give the prefix, and then you can give it a whole series of commands, based on a crib sheet that it shows you, that have that common prefix - without having to retype the prefix - before passing a different key to drop out of the mode again? That does sound potentially handy, if I have it right.
- pmoriarty 7y agoYes, though I'd describe it more as a fully-customizable popup menu that appears when you type a certain keystroke. Once the menu appears you can type more keystrokes to perform an action or bring up another custom menu. Also, it's possible to configure it so that there's a delay between the time you type a keystroke and the menu appears, so that if you remember the key-sequence you need to type to perform a certain action and you type it fast enough, then the menu won't pop-up, but if you forget the full sequence then you can type just the first keystroke and then wait a bit and the menu will pop up and remind you of what needs to be typed to execute the action you want. It's super handy, and is one of my all-time-favorite emacs packages.
- warp 7y agoWhat is the emacs equivalent of package.json? (whenever I git clone my dotfiles on a new machine I usually have to comment out a bunch of stuff in my ~/.emacs because it's referencing packages which aren't installed, and I forgot where I installed them from, what version, etc...)
- AtticHacker 7y agoI think you're looking for https://github.com/jwiegley/use-package https://github.com/jwiegley/use-package ?
- brlewis 7y agoThat looks awesome! All of a sudden I feel so primitive with https://gitlab.com/brlewis/brlewis-config/blob/master/emacs/startup.el#L22 https://gitlab.com/brlewis/brlewis-config/blob/master/emacs/...
- AtticHacker 7y agoIt's really handy if you don't use spacemacs / doom-emacs. My (old) config used it heavily. It also defined everything inside a single org file which also serves as a README on github: https://github.com/kwrooijen/.emacs.d https://github.com/kwrooijen/.emacs.d However these days I'm using Spacemacs, currently looking at Doom.
- robto 7y agoI use straight.el[0] for a reproducible package list. It basically clones the packages and stores a map of package->commit, so you can freeze your packages and reproduce them on another machine. You could also use the Guix package manager[1] or the Nix package manager[2] to achieve a similar effect. Reproducible software is much more stable! [0]https://github.com/raxod502/straight.el https://github.com/raxod502/straight.el [1]https://guix.gnu.org/#guix-in-other-distros https://guix.gnu.org/#guix-in-other-distros [2]https://nixos.org/nix/ https://nixos.org/nix/
- 7y ago
- mapgrep 7y ago> All the packages were installed from Emacs package Manager. By running, `M-x list-packages` This should bring up a list of packages available in MELPA. Now, don’t worry if you don’t know what MELPA is, just think of it as a repository of all packages, as in, analogous to the Debian Package Repo in Debian/Ubuntu distros. Article seems to confuse MELPA with ELPA. MELPA is something you have to add via your init file. Not terribly hard to do, but just FYI for anyone who is actually using these tips from scratch.
- numlocked 7y agoThe one thing I consistently do in emacs that shocks my coworkers -- is running this (custom) function, that I call "arrayify": (defun arrayify (start end quote) "Turn strings on newlines into a QUOTEd, comma-separated one-liner." (interactive "r\nMQuote: ") (let ((insertion (mapconcat (lambda (x) (format "%s%s%s" quote x quote)) (split-string (buffer-substring start end)) ", "))) (delete-region start end) (insert insertion))) What it does: Given a list of strings separated by newlines (commonly, something copy-pasted from a table) like: josh sam jed C.J. toby You select the text, and run "arrayify". You can optionally provide a quote character and, in about half a second, get to: "josh", "jed", "sam", "C.J.", "toby" This is incredibly useful for taking lists of IDs, or email addresses, or whatever, and transforming them for pasting into documents, or emails, or "in" clauses in SQL, etc. It is unbelievably useful.
- quickpost 7y agoDoesn't sound crazy at all to me! I do this all the time using multiline editing in Sublime Text. It's the one part of a more modern IDE I have a hard time giving up (transitioning to Spacemacs currently). Will have to try out this script and see if it helps bridge the gap!
- brlewis 7y agoIf emacs keyboard macros haven't bridged the gap for you, try https://github.com/magnars/multiple-cursors.el https://github.com/magnars/multiple-cursors.el Keyboard macros: https://www.emacswiki.org/emacs/KeyboardMacros https://www.emacswiki.org/emacs/KeyboardMacros
- MultusSalus 7y agoI’ve been using this for a few things, and while it’s a little more unwieldy than Sublime’s it works fine for most of my uses so I’d definitely recommend giving it a go.
- quickpost 7y ago
- molteanu 7y agoThis is mostly a listing of packages and very known ones at that. One of the best features I like is undoing regions. That is, if you know the approximate location of the text that you want to undo, you just select a region that contains that location and call undo. It can be used as a quick git alternative. Say you modify the buffer all over the place. If you want to undo some text that you've modified an hour ago but you did other modifications to the buffer in countless other places, you can undo just that region and you don't have to go back throught the whole undo tree. Another one that I've currently discoverd and I'm very excited about is yasnippet (the modern variant of abbrev). You can define a string that stands for an abbreviation for an expansion. Everytime you type that string, it is replaced by that expansion. The nice thing about yasnippet compared to abbrev is that, among others, you can specify where to leave the cursor after the expansion. One example: "lt" expands to (let ((_))), where _ is the cursor position after the expansion. This also saves typing of all the parantheses. Or "mcar" expands to (mapcar (lambda (_))). You can expand anything to anything, in short. With time, you can type less and faster.
- smabie 7y agoYasnippet is amazing. Being able to tab through different fields is a game changer. You could make a snippet for every lisp function and never have to enter a paren ever again! The only probablem is that yasnippet can’t handle multiple nested expansions: it only keeps track of the current expansion.
- celeritascelery 7y agoIf you set `yas-triggers-in-field` it will work with multiple nested expansions.
- admax88q 7y ago> you just select a region that contains that location and call undo. What the fuck, how did I not know this. I am now glad that I read this thread. So much time lost undoing a bunch of changes, killing the piece I want to restore, redoing the changes and then yanking.
- rcgorton 7y agoemacs as a binary editor: useful. Any other uses: counter-productive. I've (painfully) watched some amazingly gifted researchers/engineers using it, and saw them waste about 50% of their attention trying to use it. Emacs is not an editor, it is an OS with non-obvious semantics.
- cletus 7y agoWhenever I hear about or see the .vimrc and .emacs files people create, maintain and constantly modify to me this just looks like the perfect example of a sunk cost fallacy. IDEs are usually dismissed by many such people since you can (allegedly) do the same in vim/emacs but to me this seemed crazy as I'd see people spend hours configuring plugins, writing Lisp and whatever to save them on some task they'd get for free with a right click in IntelliJ. I really do think people completely underestimate how much time they have and will invest in such endeavours. I mean if this makes you happy or you like this tinkering, by all means be my guest, but I'll take a hard pass.
- skummetmaelk 7y agoWould you rather drive a nice car that needs some loving care and maintenance once in a while or an old banger that just gets the job done? It's the same sort of prospect. Some people like to work in a nice environment where they are able to remove all the little frustrations that less customizable tools often force upon you. When emacs annoys you at least you can fix it if it is annoying enough for you to want to do so. In any case neither choice is wrong or right. Do whatever floats your boat.
- deleted 7y ago[deleted]
- thom 7y agoYou might as well make this point about all software. Can't people just use Excel? Why write something bespoke?
- Koshkin 7y agoWhat’s Excel? apt search is not showing anything...
- QuesnayJr 7y agoThis is a strawman. Nobody endless tinkers with their .emacs file, unless they really want to. I change my .emacs file less than once a year.
- jhoechtl 7y agoI use Emacs every day. But only for org-mode which is fantastic. Besides that I really really tried hard to love Emacs as my go-to editor. However I found no alternative for decent CSV file support (like https://github.com/chrisbra/csv.vim https://github.com/chrisbra/csv.vim simply great!) Inspecting large XML files with syntax highlighting and folding. VIM is also not the fastest here but at least 10 times faster (emacs SGML mode is a joke for xml files and forcing xhtml mode of web-mode is also not that great) Maybe all my emacs doing was just wrong.
- thom 7y agoSad to see you're being downvoted for valid points. I'll admit I'm glad I don't have a job that involves staring at CSV or XML all day but I've found csv-mode and SimpleEmacsSpreadsheet lacking over the years, and large XML files can indeed be slow.
- Wildgoose 7y agoI wonder if some of the down-votes is from people who have tried to edit large XML files in the past with vi (Note: original vi, not vim) and discovered it chokes and fails to do so, complaining of over-long lines. One of the reasons I switched from vi to Emacs in the very distant past was for this specific reason. (Vim did exist, but it wasn't installed on the old Unix machines I was working on).
- smabie 7y agocsv-mode does exactly what you want.
- deleted 7y ago[deleted]
- Koshkin 7y agoEmacs is the spaceship of typewriters. Whenever I try using it, I end up feeling like a centipede who began thinking about which leg it should move first.
- jaequery 7y agoAs a long time emacs user, I'm sad to say but I've become pretty content with Visual Code and I don't think I'm going back. Ofcourse, took a lot of time customizing Code retaining all my emacs keybindings, etc.
- confounded 7y agoWhat was it that made you move, and what is it that will make you stay?
- m463 7y agoa few I use: (defun shift-left (beg end) (interactive "r") (shift-region beg end -1)) (defun shift-right (beg end) (interactive "r") (shift-region beg end 1)) (global-set-key [A-M-right] 'shift-right) ;; >> shift every line of region (global-set-key [A-M-left] 'shift-left) ;; << (and region remains highlighted) (global-set-key "\M-+" 'text-scale-increase) (global-set-key "\M--" 'text-scale-decrease) (global-set-key "\M-=" (lambda () (interactive) (text-scale-set 0)))
- arminiusreturns 7y agoOne of my favorites is creating a seperate backup dir where all backup "~" files are created and versioned and rotated in and out etc at specific intervals, so I no longer get the random files in the dir I'm working in but can still go find backups if I mess something up.
- arminiusreturns 7y agoOne of my favorites is creating a separate backup dir where all backup "~" files are created and versioned and rotated in and out etc at specific intervals, so I no longer get the random files in the dir I'm working in but can still go find backups if I mess something up. (setq backup-by-copying t backup-directory-alist '((".*" . "~/.emacs.d/bu/")) delete-old-versions t kept-new-versions 6 kept-old-versions 2 version-control t)
- yoloClin 7y agoI already use this in my shrc files: alias ls='ls --hide="lost+found" --hide="#*" --hide="*~" --hide="*.pyc" --hide="*.egg-info" --hide="__pycache__" --color=auto' But I'll be adding your item into my config for the rotated versioning, I wasn't aware that emacs does that but I assume it'll save me anything from few hours to a few weeks yearly. Thanks!
- arminiusreturns 7y agoIf you like it check out this and see if you like anything else: https://sanemacs.com/sanemacs https://sanemacs.com/sanemacs or https://www.sandeepnambiar.com/my-minimal-emacs-setup/ https://www.sandeepnambiar.com/my-minimal-emacs-setup/
- bitforger 7y agoI'm extremely surprised to not see Spacemacs mentioned in the article or the comments. Spacemacs is, IMHO, the most sane and useful default configuration of Emacs. It is friendly to people switching from vim and includes all the packages listed in the article by default (as well as many more). It has been my go-to editor for many years now; I highly recommend it.
- tomThom 7y agoI would be productive if there were an emacs that weren't a parenthesis hell and slow as molasses. I hope there's is a lumacs