Archive for category Handy Tips

How to bind caps lock key to escape key on Windows using AutoHotKey for Vim only

Here’s another Vim tip that I find very handy. When using gVim on Windows, I can bind the escape key to caplock, but only for Vim. This method relies on using AutoHotKey, an excellent tool.

First install AutoHotKey

Once installed, right click the AutoHotKey icon in the system tray and select “Edit This Script”.

A text editor will open, with the default script that executes when AutoHotKey is running.

Add the following code snippet to the end of the script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
classname = ""
keystate = ""</code>
 
*Capslock::
WinGetClass, classname, A
if (classname = "Vim")
{
SetCapsLockState, Off
Send, {ESC}
}
else
{
GetKeyState, keystate, CapsLock, T
if (keystate = "D")
SetCapsLockState, Off
else
SetCapsLockState, On
return
}
return

AutoHotKey is designed to run in the background. When Vim is running, a capslock key press will operate in an identical manner to an escape key press. Even better is the fact that the capslock status for Windows does not change when Vim is in focus.

Enjoy!

No Comments

How To Fix Grub2 Error 17 after a FakeRaid Ubuntu Reinstall

I had a problem some ago after installing Ubuntu on a RAID array, my computer would not boot and displayed a Grub Error 17.

Here are some of the links that helped me to fix the problem:

http://ubuntuforums.org/showthread.php?t=1574765

https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows

http://ubuntuforums.org/showthread.php?t=1559762

had an error 17

had to rebuild the boot partition & then reinstalling grub2

http://grub.enbug.org/Grub2LiveCdInstallGuide

put in livecd 10.4

mnt drives with \dev\mapper\nvide3gegj0 <-- number at end chroot grub install pc might fail if so, then apt-get -update to update repository listings. then install dp installer

No Comments

How to bind the Windows key to the Escape key in Vim for Ubuntu

Here’s a nice tip I’ve just discovered when using Vim on the Ubuntu OS on a computer equipped with a windows keyboard. Most PC keyboards have Windows specific keys on their bottom row, such as the Windows start menu key and the context menu key.

With the default key bindings in Vim, it can be a pain to reach up to hit the escape key to exit insert mode.

I discovered that you can bind the Windows key at the bottom row of the keyboard to act as the escape key.

To do this, you need to edit your ~.bashrc file and add the following line:

xmodmap -e “keysym Super_L = Escape”

The changes will come into effect once you restart your terminal. Then you’re good to go.

There are many alternative keybindings, and I was wary of swapping the escape and caps lock key bindings because of unintended side effects.

I had previously mapped typing jj to exit from insert mode by adding the following to my .vimrc file

:imap jj

After about a year of using jj I wanted to use something quicker and the windows key binding above was my solution.

Happy Vimming!

No Comments