Automating the Vim Workplace (2020)
sharats.me
sharats.me
What really frustrates me is how little people seem to want to invest in their tools, or the outright lies they tell themselves about how much configuration they need to use Vim on a daily basis. My Vim config is 200 lines, and my last commit was 3 years ago. I've invested maybe a few days of my life into configuring Vim and I use it 8-16 hours a day.
Vim can do so much on its own. It has autocomplete, fuzzy finding, integration with build systems, file search, navigation using a directory browser, jump to symbol, parse compiler output to jump to bugs, support for gdb and breakpoints, a built in terminal, copy to and from the system clipboard, and with literally 8 lines of code you can get support for every linter, LSP, etc. known to man, fuzzy finding, and git integration that let's you use native git commands with seamless editor integration.
I have setup neovim-dap[0] with all the related plugins, it works for simple script but it bugs out and crashes when running our Flask web app. I rely heavily on the Pycharm debugger to step through our app.
Have you had a good experience with setting up a debugger in vim/neovim or is that not part of your workflow?
For Python I find a built in debugger especially unnecessary. Most interpreted languages have a debugger that can be triggered from the source code to drop into an interpreter, and Python is no exception - see pdb and breakpoint().
Cheers
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.
It is better to have atleast some fall back capabilities(for searching across files, searching within files, sorting etc) build in.
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.
At work, though, I've been doing dev work primarily in Windows for over a decade.
Never needed WSL.
(Maybe because I use Emacs? I dunno)
May because WSL becomes a huge dependency and many windows boxes don't have it installed, whereas windows userland is always available.
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.
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).
Maybe a little less now that I’ve become a heavy user of tabs. When I start working on a unique task I create a new tab with a few splits with the files I’m interested in. In a way tab views are how I externalize my working memory. But a file tree is still useful to me because file names don’t stick so using a command or picker to swap is often slower
Works better than MySQL workbench and other things like that, for me, because it works in a terminal over ssh too.
I usually develop full stack so will have a front end tab (with multiple Vim buffers), a backend tab (again with multiple buffers), dev servers, a database sql tab (if needed) and a command line tab to grep and git and whatever else.
Might sound kind of awkward but it's muscle memory by now and blazing fast for my use case.
The one thing I have not figured out yet is how to cleanly integrate AI tools into my workflow. A lot of cutting and pasting which feels very clumsy. I don't want to give up Vim nor my basic workflow. I never used co-pilot just GPT.
I used to use your setup, and I was fast. But tmux is much better. (I'm also a full-stack dev btw)
Another advantage, I can ssh into the server, start a tmux session, and work there the same way I do on my local. Doing that your way would require a lot of ssh sessions.
> The one thing I have not figured out yet is how to cleanly integrate AI tools into my workflow
Tips: use `/ask` if you don't want it to make changes, and try to use it for small incremental commits, instead of broad sweeping changes. That may change soon with these reasoning models, though.
It's also good for writing shell commands.
nmap <F2> :silent! wa<CR>
Copy to System Clipboard if has('unix')
set clipboard=unnamedplus
else
set clipboard=unnamed
endif
Also, to type word under cursor into command line: cmap <M-w> <C-R>=expand("<cword>")<CR>
Paste without replacing clipboard (for the lazy): vnoremap p PYou can also achieve this with <C-R><C-W> in command mode. It is inbuilt. Not sure if it's a vim or a neovim feature though.
honestly, I like articles that are “a list of vim tips”. I can usually find some really good ideas that I didn’t consider. The tip about remapping copy to system clipboard to something easier than ‘“+y’ is genius, definitely using that.