Inspired by $\rm \LaTeX$-Suite, I added some autocompletion mappings in my VIMRC last year.1 Three months later, I saw the word “FileType” in Vim’s User Manual, and shortened these autocommand a little bit.2 In my opinion, it’s incredibly amazing since I can type text at the speed of thought.
If I’ve finished editing an HTML file and open another $\rm \LaTeX$ file, then my insert mode mappings will interfere with those defined by $\rm \LaTeX$-Suite. How can I restrict my custom mappings to the current working buffer only?
Since I didn’t know how to describe this problem in words in February, I spent hours searching for webpages on Google, but got nothing. At that time, I had focus on my homework and exams, so I put this problem aside. As a GNU/Linux user, I adjust my wants according to what I know and what I can do, after accepting the fact that M$ Off* has no known plan to support the free operating system.
Last night, when I wrote a recent linklog about Vim’s auto indenting, I did some configurations on Vim. This reminded me of hte problem of setting up autocompletion for brackets. After writing over 150 blog posts in Vim, I realise the inconvenience without these keyboard shortcuts for autocompletion in the insert mode.
First, I glanced through the codeblocks in the cited posts in the first two footnotes. After that, I googled “autocmd group”, and found two sites very useful.
Vim inoremap for specific filetypes on Stack Overflow.
<buffer>is the missing part of the autocommands.
Autocommand Groups on Learn Vimscript the Hard Way.
View my VIMRC on M$ Win* 7 at commit c11d1a1.
This morning, I tried to write similar keyboard shortcuts for ‘'’, ‘"’ and ‘`’ at lines 62–63 and 67. However, typing two ‘"’s quickly on M$ Win* 7, GVim duplicated my input. Therefore, I changed the rules so that they would only be invoked when one quickly typed any one of these characters twice.