Use shortcut to replace “Esc” in VIM/GVIM

March 22, 2007

I bought a second hand Canon 300D recently. Had much fun with it. I’ll probably write something about using a DSLR in Ubuntu. Really love this “old” camera.

OK. Here is the problem I recently found when I was using GVIM-latex-suite to type my final thesis, when I want to change back to normal mode from the insert mode by pressing “Esc” it is quite unconfortable. Although “Esc” key is not far from other keys, it is just not that convenient. Because when you typing, your fingers are alway around “ASDF”and “JKL:” keys. You’ll need to move your hand to reach the “Esc” key…

This can be quite easy to solve. I am sure there is a way using VIM setting itself to remap Esc key. But don’t want to research such settings. The KDE control center, can do this quite easily. Here is the steps:

  1. KDE control center-> Reginal & accessibility-> Input Actions.
  2. “New Action”. Note you’d better to create a new group first.
  3. Go to “Trigger” tab, “New”-> Shortcut Trigger-> I use “Right Alt +  L”. It’s quite convenient when you are in the type position. Try it yourself.
  4. Go to “Actions” tab, “New”-> Keyboard input -> type Escape.
  5. Leave all the other settings default.

That’s it. Now in every active windows, if you press “Right Alt+L” the actual key activated is “Esc” key. Enjoy your VIM typing!

HOWTO: make vim latex-suite always recognise tex file

January 9, 2007

Although the KDE latex tool Kile looks very nice to me, I like use the famous vim editor with its latex-suite to edit my latex files. I got a problem with this editor recently. The problem is that vim can’t invoke my tex file automatically. For instance, there is an empty file called “empty.tex”. If I open it with vim, the latex-suite won’t load automatically. As long as I added some latex keywords like “/usepackage”, vim would recognise this file as latex tex and load the latex-suite.

I searched the vim “filetype plugin manual” and got —

Vim can detect the type of file that is edited. This is done by checking the
file name and sometimes by inspecting the contents of the file for specific

So it seems that vim detect the latex tex file by the content of the file, not the extension name “tex” . After some searches, I found there are three ways to make sure the latex-suite will be loaded if the file have a tex extension name.

  1. In the vim when edit the file. Use “: set filetype=tex
  2. Put this line “/* vim: set filetype=tex : */” in the file.
  3. vim ~/.vimrc. add this line: “let g:tex_flavor = “latex”“.

I think the last method is the best.