Friday, 9 August 2013

Is it poosible to have per file type key mapping in Vim

Is it poosible to have per file type key mapping in Vim

I just discovered lately that when you enter a non breaking space(nbsp) in
an HTML document
and set the encoding to utf-8, you wont' have to enter nbsp; repeatedly to
format text. I at first
thought, hey, why don't I map this to the space bar like so :imap <SPACE>
<C-R>=nr2char(160)<CR>.
I later edited my .vimrc and when I restarted Vim, I got dozen errors
about some function needing a
name even though I had given it. I realised that the nbsp is not treated
as a space(duh) even though it
looks like one. So, I thought a better way would be to have a per file
type mapping, so that I when I am editing a html document, the space
inserts an nbsp and a normal space chr(32) when editing any other file.
How do I do this?

No comments:

Post a Comment