Here are some of the top Vim posts from Today I Learned.
Today I Learned is now over a year old.
The participation from my coworkers has been inspiring, rocketing our posts count to over 750. The enthusiasm from fans of the site has been encouraging, on Twitter, Hacker News, and elsewhere. We open-sourced the codebase earlier this year and have gotten issues and pull requests, as well as several clones in production. It’s been awesome.
TIL content is like a river; if you haven’t posted today, your content gets lost in the stream. That’s why I’d like to pause and highlight some of the top posts from the first year of Today I Learned.
Beyond a chance to reflect, I hope we can all benefit from the hard-won epiphanies of Rocketeers at work. Leverage the head-banging of others!
We’ll start with Vim, our first and most active channel. Below are the top five most liked Vim posts, in order, from the first year of Today I Learned.
Up until now I was editing all my blog posts in Atom for lack of markdown fenced code block highlighting in Vim. Atom supported it out of the box. As it turns out Vim can do that too, out of the box!
If you are running a recent version of Vim (mine at time of writing 7.4.9910) you can setup highlighting for fenced code blocks in markdown.
Open your .vimrc and add the following line:
let g:markdown_fenced_languages = ['html', 'vim', 'ruby', 'python', 'bash=sh']
You can customize it to your liking and add more languages.
> Note: Not all languages are supported but you can try and see if they work. To see a list of languages you have installed on Mac (with Vim installed by Homebrew) run
ls -l /usr/local/Cellar/vim/7.4.1190/share/vim/vim74/syntax
This is a game changer.
If you want to switch the case in Vim:
gu => lowercase
gU => uppercase
g~ => toogle case
You can also combine with Vim motions like:
g~ip => toogle case for the current paragraph.
If you typed a command in Vim’s command line and want to repeat it you can open the command-line window and browse through past commands. There are two ways two do that:
- From Normal mode type
- From the command line after typing a colon press
In the command window you can browse up and down with HJKL and hit
return to re-run the command.
There are a number of ways to delete from the cursor position to the end of
the line. Generally when I am doing this, I want delete to the end of the
line and then start typing something different. Perhaps the best way to do
this is by hitting
C. It deletes to the end of the line and then leaves
you in insert mode. This also makes for easier repetition with the dot
This is synonymous with hitting
:h C for more details.
h/t Dorian Karter
Switch the free end of the cursor in Vim’s VISUAL MODE.
o while selecting and the free end will go to the beginning of your selection.
Thanks to Josh, Dorian, and Vinicius for those posts.
Today I Learned had a spike in traffic near the beginning of the year, and these posts are mostly from that time. But there’s a lot of great Vim tips from earlier. See them all here:
Keep composing those commands, and learning every day.
This post is part of a series. Stay tuned for my next post, when we will look at the top SQL posts from year one.