My thoughts on Computer Science, Math, Statistics and product development.
Recent Posts
Checking spelling
Vim has a built-in spell check that you can enable with :set spell
. You can
also set the language with :set spelllang=
followed by the two-letter code of
the language and optionally a dash and the region (e.g., :set spelllang=en
or
:set spelllang=en-GB
).
After enabling the spell checker, you can move between different mistakes with
]s
and [s
.
I knew about the spell check, I knew Vim highlighted spelling mistakes, and I knew how to move between the mistakes. I usually fix them manually and I never bothered to learn how to make Vim fix them for me. Until today.
`:read` the output of a command into the current buffer
If you want to use the output of a command inside your file, you don’t need
to exit Vim, run the command, copy the output, return to Vim and paste the
contents. You can use :read
(or abbreviated to :r
) and run a command
with !
. For example, :r !ls -a
will insert the output of ls -a
at
the current cursor position.
You can also insert the content of another file with :r
, except this time
you don’t use !
, just the file name. For example, :r second_file
will
insert the content of second_file
at the current cursor position.
Changing capitalisation of words
In Vim, while in normal mode, if you type ~
, the capitalisation of the
letter under the cursor changes and the cursor is advanced to the right.
You can also change the capitalisation of multiple letters at the same time
with g
command. Type gU
and a movement to make every letter corresponding
to the movement to become uppercase. gu
makes it lowercase and g~
toggles
the case. You can repeat the last character to affect the whole line (guu
,
gUU
, g~~
).