Quickly Fix A Misspelled Word

I just learned that you can have automatically fix a misspelled word with the top suggestion by typing: 1z= This is opposed to the regular z= command for opening the regular list of spelling correction options. Like Josh who I learned this from, I usually pick the first option so this is a bit more convenient.

Vim for React Developers

Vim for React Developers For anyone who is vim-curious, I think this is a cool approach to learning practical uses for vim. The “course” is just a react source file (direct link) with the instructions as comments describing how to modify the various bits of code throughout the file. Even though the file is a react component, examples are largely just as applicable to most programming languages (especially those with c-like syntax) as well as editing regular HTML. ...

Move a line with :m

Today I learned that you can move the current line up or down with :m. :m +1 - moves down 1 line :m -2 - move up 2 lines I’m used to using dd followed by a movement and then p but I may try this alternate method.

Pressing `%` will also jump to the matching HTML tag

I’ve used % for some time now in vim, but I only just today learned that it not only jumps to a matching bracket or parenthesis, but also a matching HTML tag! Unfortunately this doesn’t seem to work with vscode-vim but it does work with vscode-neovim. You could also accomplish this by assigning a hotkey to the “Go to matching pair” Emmet command.

Split lines in Vim

I’ve long wanted a command that was the opposite of J (join lines), and I finally took the time to see if it’s possible. Turns out there a few solutions. The simplest way if you want to split on a whitespace character is to just type r enter. I can’t believe I never thought of that before. You can also install the vim-split-line plugin, which adds the :SplitLine command. This command will split the current line at the cursor position. ...

b is an Alias for Parenthesis in Vim

I just discovered that b and B are aliases for the () and {} text objects respectively. This is a nice little builtin improvement since I frequently find myself selecting or changing withing parenthesis and cib is nicer to type than ci(. I only wished I’d discovered this years ago!

Vim sets auto marks

Today I learned that Vim has some special marks which it sets automatically: Command Description `. jump to position where last change occurred in current buffer `" jump to position where last exited current buffer `0 jump to position in last file edited (when exited Vim) `1 like `0 but the previous file (also `2 etc) '' jump back (to line in current buffer where jumped from) `` jump back (to position in current buffer where jumped from) '[ or '] jump to beginning/end of previously changed or yanked text '< or '> jump to beginning/end of last visual selection The funny thing is VsVim displays these in the gutter by default and I never knew what the symbols meant. Vscode-vim has an option to display marks in the gutter but only the regular marks and not these. ...

Git rebase.abbreviateCommands

This is probably a very niche use case, but I learned today that you can abbreviate commands that git populates in the todo list during an interactive rebase. So it’ll look like this: p deadbee The oneline of the commit p fa1afe1 The oneline of the next commit You can enable this with git config --global rebase.abbreviateCommands true. To be clear, you can always use the abbreviated commands, but since I use Vim to edit the list, it makes it slightly more convenient to edit the commands. ...

Quit vim with :x

People like to joke that vim is impossible to exit, but I just discovered that there are actually several different ways to quit and :x is my new favorite. The :x command will save and quit but it differs from :wq in that it will only write the file to disc if there were any changes so the modified date of the file won’t get updated unnecessarily. This seems like the preferred behavior most of the time. That coupled with the fact that it’s slightly faster to type has made it my new default way to exit vim. ...

Open a URL in vim with `gx`

Pressing gx while over a URL in vim will open that url. Confirmed it also works in vscode-vim.