Linux Tip: Stop cursor blinking in GNOME Terminal (version 3.18.3 and older)

Time: less than 1 minute.

If you spend a lot of time in the terminal, having the default blinking cursor can be annoying. This tip is for turning off blinking in GNOME Terminal, which is the default terminal emulator on Ubuntu.

For version 3.18.3 (come with Ubuntu 16.04) or newer, run this in the terminal:

gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$(gsettings get org.gnome.Terminal.ProfilesList default|tr -d \')/ cursor-blink-mode off

For older versions:

gconftool-2 --set /apps/gnome-terminal/profiles/Default/cursor_blink_mode --type string off

The effect should be right away without re-login.

If you’re unsure about your GNOME Terminal version, run this to check:

gnome-terminal --version

Linux Tip: Map CAPS LOCK key to ESC on Ubuntu

Time: less than 1 minute.

If you use Vi/Vim, you probably want to map CAPS LOCK key to ESC because it’s much more convenient. It’s also more natural because the original position for ESC, when Vi was invented, was actually near the CAPS LOCK position in modern keyboards.

For the official Ubuntu’s desktop environment, which is GNOME, install this following tool to tweak the key mapping:

$ sudo apt-get install gnome-tweak-tool
# then run
$ gnome-tweak-tool

There are all kinds of thing you can tweak, not just CAPS LOCK key, but for our purpose:

Go to typing panel, then Caps Lock key behavior, and check Make Caps Lock an additional ESC


The effect is taken immediately and permanently. Now you can close the program.

Vim Tip: Fix plugin loading error “Not an editor command: ^M”

One of the most annoying errors you probably already encountered  with Vim terminal (not GVim) on Windows when you use Vim plugins that were obtained through Git (via plugin manager like Vundle, Pathogen, etc.) is this kind of error message:

E492: Not an editor command: ^M
line    9:
E182: Invalid command name
line   10:
E492: Not an editor command: ^M
line   12:
E182: Invalid command name
line   13:
E492: Not an editor command: ^M
line   15:
E182: Invalid command name
line   16:
E492: Not an editor command: ^M
line   18:
E182: Invalid command name

This error is reported and asked so many times on StackOverflow and GitHub, and the answers provided are mostly about removing the special character or setting file format to “unix”. However, that wouldn’t solve the problem.

It took me a very long time (I gave up many times) to finally find out the solution through this GitHub issue on Vundle. It wasn’t something many people would expect. Turned out Git’s default setting to deal with line endings is not sufficient.

All you need to do is to config your Git correctly before cloning Vim plugins:

$ git config --global core.autocrlf input

That’s it. Now you can install Vim plugins like normal.

For more information about the above Git setting, see here.

Vim Paper Color Theme

I started using Linux and Vim last Summer, and one of the first things I did in Vim, like I would do in any code editor, was to find a decent color scheme. I was surprised by how useful and colorful the terminal could be. Coming from Windows background, I realized how much I missed out. At first I was happy with the themes I found, but as I worked with less mainstream languages, most of the themes don’t work well enough. Or, some work on these languages but not on the others, so I had to switch theme based on the language I was programming, and it quickly became annoying. So, I decided to create my own color scheme.


Read more