5 ms·
After reading this I'm reminded that if an IDE just supported replacing highlighted text after it was piped through a command it would have a lot going for it.
by gravypod 10y ago
After reading this I'm reminded that if an IDE just supported replacing highlighted text after it was piped through a command it would have a lot going for it. A lot of these are features some that IDEs have been lacking for years yet they've been hiding away in /bin.
- tambourine_man 10y agoFWIW, you can do that in Vim. Select text then: :'<,'>!command
- my_ghola 10y agoAnd `%!command` to replace the whole file. That's how editing hexadecimal in vim works. `%!xxd` to turn it, then `%!xxd -r` to turn it back. Another useful one is `%!jq .` to pretty print a json file.
- susam 10y agoI use this often. I usually enter `:%!xxd -g1` to show each byte value separately instead of showing two bytes together. $ printf "\x00\x01\x02\x03" | xxd 0000000: 0001 0203 $ printf "\x00\x01\x02\x03" | xxd -g1 0000000: 00 01 02 03 While editing binary files in Vim, one needs to be careful about setting the binary option before editing a binary file or opening the binary file with `-b` option. For example, printf "\x00\x01\x02\x03" > a.bin vim a.bin :%!xxd -g1 would display 0000000: 00 01 02 03 0a ..... (The `printf` and `vim` commands are entered in the shell. The `:%!xxd` command is entered in Vim.) In the above example, a newline has been added by Vim where none existed in the binary file. In fact, if you then run `%!xxd -r` followed by `:w`, this additional newline would be written back to the file. Here is the right way to preserve the binary data in a binary file. printf "\x00\x01\x02\x03" > a.bin vim -b a.bin :%!xxd -g1 would display 0000000: 00 01 02 03 .... Only the four bytes in the file appear now. Alternatively, one may enter `:set bin` in Vim before editing a binary file.
- noisy_boy 10y agoYou can also use a range e.g. `5,10!column -t` would align columns for lines 5 to 10.
- salgernon 10y agoMPW - macintosh programmers workshop circa 1988 (when I first used it) had the notion that selections within windows could be treated as just another file. It had a lot of posix-y commands but lacked multitasking and all pipes were done via temp files, alas.
- ihodes 10y agoIn emacs, `C-u M-| cmd <enter>` does this.
- black_knight 10y agoAcme, the text editor from Plan 9 has this. Piping, inputing and outputing from commands are some of the most basic operations there. Check out: - http://acme.cat-v.org/ http://acme.cat-v.org/ - Russ Cox' tour: https://www.youtube.com/watch?v=dP1xVpMPn8M https://www.youtube.com/watch?v=dP1xVpMPn8M
- gravypod 10y agoIs there an updated version with less complicated mouse interfaces?
- Veen 10y agoThis is what BBEdit filters do: http://bbeditextras.org/wiki/index.php?title=Text_Filters http://bbeditextras.org/wiki/index.php?title=Text_Filters
- badsectoracula 10y agoIn my previous job i wrote an extension for Visual Studio to do exactly that: call a program with the selection, pass the input to its stdin and replace the selection with the output. Then i wrote a bunch of Python scripts to do things like recalculating command id's for wxWidgets, generating the registration, header and body parts from event definitions (which i cut/pasted later, but it was much faster than doing that by hand), aligning some declarations to fit with the code style, etc. The extension would also scan a folder inside My Documents and register any executable, python script, bash script and tcl script to a menu in the IDE. Many people in the studio knew Python and some new Bash (i think i was the only one who used Tcl though, i mainly used it to quickly search the filenames for the project and open a file in VS or Vim. I made it to search as i type and since we had a more or less 1-to-1 mapping between objects and files, i could search for object definitions faster than using VS's search functionality - especially when VS was busy building or doing stuff).
- dotancohen 10y agoThe KDE text editor, Kate, has this. It is absolutely wonderful, and Kate is full of such gems.
- vanviegen 10y agoKakoune makes this a central concept. Just hit pipe ('|') in normal mode. It even works for multiple selections!