Refreshing vim plugins in 2021

Useful VIM tricks for 2021

It's been a while since I started using Vim. The movements and edits I do on a regular basis have felt natural for quite some time. But I haven't spent time exploring additional commands that might help in situations I regularly end up in where I still don't have any shortcuts to use.

And what's a great way to learn something new? To try to teach it to others!

Here are some useful vim commands and plugins that makes sense for common situations. (At least in my own context).

Surround.vim

A lot of edits consist of changing the surrounding tag or character for some reason. Maybe you're switching out a component in React for something else, or converting a string to a template literal in JavaScript. Surround.vim is a neat plugin that only operates on surroundings.

For the component switch, let's say you want to switch the quotes around "My string" with ':

<h1>Hello world</h1>

While the marker is "inside" the string, simply hit cs"' and the quotes will be replaced with single quotes.

Commentary.vim

Commentary.vim is really useful for commenting or uncommnenting one or multiple lines in a file. The gcc toggles the current line as a comment or not, while the gcgc toggles multiple adjacent lines as comments.

Both of these plugins are made by the same person, so thank you Tim Pope for these lovely little pieces of neat vim plugins.