macOS Tip: Map CAPS LOCK key to ESC

Quite often, ViM users like to map Caps Lock key to something else more useful such as Esc or Control. In the case of the new MacBook Pro keyboard with touch bar, the Esc key is on the touch area that gives no tactical feedback to your finger, and it can be very annoying especially when it is the most often used key in ViM to switch between editing and command mode.


I wish I had bought a non-touch-bar version of MacBook Pro because after 2 years using this, I never found the touch bar to be useful. I was an early adopter and thinking that this would be practical someday. Sadly, that was a $200+ mistake just so that I can adjust screen light and volume via a touch area, and even worse, I have to look at the touch bar every time to know where the on-screen buttons are. So quick advice to developers alike, save yourself $200 and just get a non-touch-bar version if you are shopping for a new MacBook Pro.

I have always been using Caps Lock key as Esc since I started using ViM, so the touch bar doesn’t bother in ViM. However, I know some people still use the physical Esc key, and if you own a touch-bar MacBook, you might want to start switching to Caps Lock now.

Fortunately, mapping Caps Lock key to Escape or Control key on macOS is very easy. You don’t have to install any additional software to do that.

Simply go to System Preferences

Screen Shot 2018-07-22 at 6.09.00 PM

And go to Keyboard page. Then, click on Modifier Key… button near the bottom right corner, and the rest is self-explanatory.

Screen Shot 2018-07-22 at 6.11.59 PM

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

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

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.

Linux Tip: What to do after accidentally removing Ubuntu Desktop essential packages

OS: Ubuntu 14.04 (different Linux distros can have similar problem, so Google the appropriate commands for your specific distro)

Short Answer

Reinstall the packages from the standard Ubuntu Desktop that you removed:

sudo apt-get install ubuntu-desktop^

Long Answer

Continue reading “Linux Tip: What to do after accidentally removing Ubuntu Desktop essential packages”

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.


Continue reading “Vim Paper Color Theme”