Live data from Hacker News

My Emacs Productivity Tricks/Hacks

mycpu.org

111–120 of 210 posts

Re: My Emacs Productivity Tricks/Hacks

#111

Earlier quoted context omitted.

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

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.

I'll be that guy ;)

In vim/unix you can run this command (keybinding not included but simple enough):

  :'%!awk 'BEGIN {ORS=" "} {print "\" $1 "\"," }
As for a unified computing environment, it is unified with the OS and not a world unto itself, there is no need to have one way of doing things within the editor and another if you want to script something. Both work just as well with version control, plus it gives you the flexibility to change text editor, like from vim to kak.

Speaking of kak, multiple cursors > any of these scripted options.

Re: My Emacs Productivity Tricks/Hacks

#113

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 a similar function. I find the inverse also very useful - especially for diffing things

Re: My Emacs Productivity Tricks/Hacks

#114
post #34

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

Can'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.

Re: My Emacs Productivity Tricks/Hacks

#115

Earlier quoted context omitted.

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

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.

> Once you bind it to a key, though, it's a lot quicker.

but that's something any IDE in the world can do ?

Re: My Emacs Productivity Tricks/Hacks

#116

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…

In vim:

    :'!awk '{printf("\"\%s\", ",$0)}'
or to do the whole file:

    :%!awk '{printf("\"\%s\", ",$0)}'

What I find nice about this approach is that I can use my knowledge of awk in other non-vim contexts. Similarly I can use my knowledge of other text processing commands to do things in vim, like reformat text into columns (:%!column -t) for example.

Of course you could use vim commands to do the same thing:

   0GI"$GA", VGJ
Which would have the benefit of making it more customizable at the expense of....well you can see what you have to type.

Re: My Emacs Productivity Tricks/Hacks

#117
post #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.

To run the macro as many times as possible, M-0, F4 (Alt-0, F4).

Re: My Emacs Productivity Tricks/Hacks

#118

This 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 b…

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

Re: My Emacs Productivity Tricks/Hacks

#119
post #60

Earlier quoted context omitted.

All decent IDEs have a file search command.

I 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

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

Re: My Emacs Productivity Tricks/Hacks

#120

Earlier quoted context omitted.

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 .

Or use the C-u 0 prefix to repeat till there is an error, possibly at the end of buffer. And if you don't want to go on to the end of the buffer, narrow to the required region (C-x n n) and widen afterwards (C-x n w).
Post reply on HN