Live data from Hacker News

My Emacs Productivity Tricks/Hacks

mycpu.org

101–110 of 210 posts

Re: My Emacs Productivity Tricks/Hacks

#101

The 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 in…

I have used Excel's TEXTJOIN function for such cases.

Re: My Emacs Productivity Tricks/Hacks

#102

The 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 in…

I achieve the same by running two consecutive regex search and replace and a single backspace click

    s/^/"/
    s/\n/“, /
(Change all beginning of line to double pling. Change all new lines to double pling, comma, space)

I don’t even store this as a procedure, I just ctr-f and do it from whatever text editor I’m in (I’m not an Emacs user)

The nice thing about search and replacing your way out of problems is that it works on coworkers machines.

I’m not saying it’s better than a stored procedure or a macro but once you’re into it, it’s easy to regex your way out of all sorts of adhoc problems :)

Re: My Emacs Productivity Tricks/Hacks

#103

I 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 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 fil…

Sad 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.

Re: My Emacs Productivity Tricks/Hacks

#104

Earlier quoted context omitted.

Yes, indeed. You can also do that, and other small variations on it depending on the context, with a macro. You go to the end of "josh", press F3, add a comma and a space and you delete the rest of the line, until "sam" is now the next symbol after your cursor. Then you go to the end of the line (C-e) and press F4. Your macro is now recorded. To call it, press F4 repeatedly until everything is on one line. As a bonus…

Works well for a few dozen entries...less so for a few hundred or a few thousand :)

Emacs keyboard macros can easily operate on thousands of things. Just give it a prefix argument like C-u 1000 .

Re: My Emacs Productivity Tricks/Hacks

#105
post #89

Whenever 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 fr…

This 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.

Re: My Emacs Productivity Tricks/Hacks

#106
post #100

Earlier quoted context omitted.

Once you bind it to a key, though, it's a lot quicker. There is something to be said for emacs as a unified computing environment when compared to the UNIX way of doing things. Instead of wrangling different parts of the filesystem and tying them together with aliases and shell scripts, you can just version-control the productivity software (i.e. your emacs config) you write in the course of using emacs.

And now since I'm sucked into the cult of the helm-o-verse I find I am binding many fewer keys. Just start typing 'M-x ar' and now it's the second item. Add another 'r' brings it to the fore. Less (for me) to remember. I note this mainly because it took me quite a long time to grok helm. Keep working with it!

You don't need Helm for that: smart M-x aka "smex" accomplished that for me and let me stay with ido, as I find Helm too intrusive.

Re: My Emacs Productivity Tricks/Hacks

#107

The 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 in…

I'd always write a basic macro by hand in such a situation: F3, ", END, ", comma, DEL, space, right arrow, F4 however many times I need.

Re: My Emacs Productivity Tricks/Hacks

#108

I 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 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 fil…

I 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).

Re: My Emacs Productivity Tricks/Hacks

#109
post #60
post #2

Helm-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.

All decent IDEs have a file search command.

Somehow 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)

Re: My Emacs Productivity Tricks/Hacks

#110
post #79

Earlier quoted context omitted.

I am developing a headache now, after trying this out, because I'm remembering all the times I have done this by hand. Or even writing an awk script, etc.

hm, I just select the text and do xclip -o | awk '{ print "\"" $0 "\"," }' find it simpler than 10 lines of lisp but what do I know :p

Easier: C-u M-| will run a console program against the text.

It's great for running sort, awk, sed, etc.

Post reply on HN