Home » Questions » Computers [ Ask a new question ]

Vim Hotkeys For Specific File

Vim Hotkeys For Specific File

Is it possible to set hotkey for specific file types in vim.

Asked by: Guest | Views: 51
Total answers/comments: 2
Guest [Entry]

"~/.vimrc

autocmd FileType java map <F5> :! javac %<cr>

More info about key mapping and external commands."
Guest [Entry]

"I don't have any direct experience writing anything like this from scratch with Vim, but here's what you'll want to look for examples to follow.

You probably want a filetype plugin (ftplugin) for .java files:

A filetype plugin is like a global
plugin, except that it sets options
and defines mappings for the current
buffer only. See
|add-filetype-plugin| for how this
type of plugin is used.

And use it with a mapleader+hotkey:

To define a mapping which uses the
""mapleader"" variable, the special
string """" can be used. It is
replaced with the string value of
""mapleader"". If ""mapleader"" is not set
or empty, a backslash is used instead.
... To define a mapping which uses the
""mapleader"" variable, the special
string """" can be used. It is
replaced with the string value of
""mapleader"". If ""mapleader"" is not set
or empty, a backslash is used instead.

You might have a look at the Vim JDE scripts, or this guide on configuring Vi(m) for Java development. This page has some information on using javac in Vim."