I hate this so much that I wrote a pair of programs (line and word) to resolve it. Here are three examples of using them: getting all IP addresses, copying one of several paths to the clipboard, and isolating a filename in a paragraph of output.
If you invoke line or word without an argument, it will print the output with line numbers. An argument will isolate the lines or words you specify. Word accepts negative indices like Python. Line does not, because I didn't want to hog memory reading all of stdin into a buffer, though it wouldn't be hard to add, and it's not unreasonable since this is mostly for use with small buffers. Neither program accepts ranges, because I didn't have lots of time to spend.
You can get the code here: https://github.com/strictlymike/pipe-slice
This is why I run shells out of emacs.
ReplyDeleteThat's interesting. I always wanted to learn Emacs, but after I invested the time in Vim, I had less reward waiting for me for learning to use Emacs (I already know one programmer's editor) and some of the chords requiring multiple keys were a bit arduous. But I still look on with wonder and curiosity when I see an experienced colleague bust out Emacs.
DeleteI use evil-mode. All that vim knowledge isn't wasted then! And you can avoid the awkward key bindings with something like Spacemacs.
Delete