a person doing computer programming

More Vim magic and moving to VSCode


OK, some more crazy Vim tricks. I have vi sets so that a window pops up with lint errors and this can be annoying. Turns out there is a hack to close windows quickly. Normally I do a CTRL-W CTRL-W to get to the window and then can do a zz to close it. but it turns out that you can do a :2q to close the second window in addition the regular :q

Another crazy trick is matching things and then replacing them. I had this problem that someone was using three backquotes around everything and the markdownlint just hated it, so how to remove everything around something? The easiest way turns out to use the idea of a context and then search for one or more characters, so here are some tricks:

  1. The normal thing to do is to search for .* but this matches zero characters. Since the triple backquotes can also be part of a quote block, you want at least one character before the string, so you want .\+ which is the more usual .+ but the plus itself needs an escape as the + could just be a character to search so the first part is the search for lines
  2. Then you want to capture that for later, then you need a grouping expression where you wrap what you want to later emit with \( and \) where the backslashes are again to tell vim that these are control characters
  3. Then in the replace, you just put the second call of the stuff in the middle with \1

Time to move to VSCode with Vim mode

And finally, as Alex said it's probably time to move to VSCode, it is getting better and better and all these plugins are cranky. For instance, Deon found a plugin for docker, so you can just directly edit into a container. Got to start using that and start with VSCodium which removes the instrumentation from VSCode and then start the plugin wars by enabling Vim mode. The main thing here is reaching down into VSCode and extracting the json that controls it.

Related Posts

This site uses Akismet to reduce spam. Learn how your comment data is processed.