What was your first text editor when you started using Linux/Unix? Mine was pico. It was very easy to get started with and quite similar to
nano. Then I moved to
emacs and sticked with it for a long while. Eventually, I’ve switched to
neovim), and that’s what I have been using until now.
Well, the thing about text editor or may be this also applies to many other things, you’re only familiar with features that you constantly use. This means I only know a small subsets of what
vim can do.
Today I came across a problem (or a feature) in vim running on FreeBSD. The issue with the automatic string replacement - everytime I type or copy string contains
256, it’s automatically replaced by
For example, in the following text file
AES256 is replaced by
zabbix_agent_psk_key: !vault | $ANSIBLE_VAULT;1.1;AES<t_CO>
I didn’t know why! I tried to search for helps on Google a few times with hit and miss. Then, the last search pointed me to the right direction.
The problem was caused by a variable defined in vim configuration:
~/.vimrc. This can be confirmed by searching for
t_CO in that file.
❯❯❯ rg t_CO ~/.vimrc 31:set t_CO=256 "Use 256 colors. This is useful for Terminal Vim.
According to brammool, the name of the variable to be set in
~/.vimrc should be
Let’s fix this by updating the variable in
sed command is slightly different to
sed on Linux. I have to pass an empty string (
-i to indicate that I don’t want to make a backup file for the original one.
❯❯❯ sed -i '' 's/t_CO/t_Co/g' ~/.vimrc
Let’s verify this:
❯❯❯ rg 't_C[o|o]' ~/.vimrc 31:set t_Co=256 "Use 256 colors. This is useful for Terminal Vim.
256 no longer gets replaced by