I have a text file where I keep my personal notes. They're structured in a certain way, so I can operate on those notes with vim commands. I would like to map a keyboard shortcut to a specific set of commands, but that mapping should be available only in this file. So I tried writing a modeline at the end of my file, like this:
# vim: nmap \a A [a]<ESC>
Unfortunately, that didn't work: when opening the file, vim says
Error detected while processing modelines:
line 273:
E518: Unknown option: nmap
How do I set a mapping that only works in this file? Preferably without writing to .vimrc or another file. Also, my file doesn't have a filetype, it's just text, and the file doesn't have any extension.
filetype
in a modeline, then add your map (with the<buffer>
qualifier if you want, cf.:h :map-<buffer>
) to a correspondingftplugin
file. Thefiletype
can be a made-up name, it doesn't have to be a well-known type.