by porridgeraisin · 1y ago · 0 comments
Vim can run shell commands as filters over selections as well.
Although vim does provide its own `:sort`, you can also sort the current selection like
v{motion}!sort
Which uses the external sort command (coreutils)For reversing,
v{motion}!tac
Which uses `tac` to reverse the order of the lines.This general concept is quite useful in many other ways, since it is quite universal - selection goes to stdin of arbitrary program, stdout of that program replaces selection.
For example, if you want to quickly test a function that takes a json string, and you're in a language where instantiating good mock objects and serialising it takes quite a bit of code, you can quickly make a mock by writing JS code within the string quotes and have the code console.log json and then `vi'!node` will replace it there.
There's `Psh` that pipes part of a line through a shell command, and `P` which takes any `ex` command and does the same (this means `P !` is the same as `Psh` but the latter supports tab completion for shell commands).
It is better to have atleast some fall back capabilities(for searching across files, searching within files, sorting etc) build in.
The author likely has git, which provides a userland. And she/he is talking about gvim.exe, so is not restricted in what she/he can choose to install, and by now, might be using nvim-qt.exe.
Edit: just realized it always posed itself as a “building platform”, lol. It really is a full-blown GNU system that works on windows. As in GNU/Linux, but there’s no linux kernel. All the /usr/bin tools are there, including pacman as a package manager (from Arch). You can install virtually everything from there.
Notwithstanding that the third party userland is possibly not necessarily, since the windows userland most likely has all the features needed for Vim to make these functionalities work.
Since the editor is intended to be a multi-plaform product, it is better if atleast a windows userland based mechanism could be provided on windows platform, if the mechanisms could not be achieved through an inbuilt platform-agnostic manner.
What if you need a "portable" ( in the windows sense of the term, it means that the program can be used without need for an installation process) version of the editor?
I think it all is a huge time sink on the end user, who would instead get some usefull progress done on their projects.