Is it possible to set hotkey for specific file types in vim.
For example, if I am editing a .java file, I'd like vim to run javac .java when I press 5.
Is this possible?
|
feedback
|
|
~/.vimrc
More info about key mapping and external commands. | |||||||||
feedback
|
|
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:
And use it with a mapleader+hotkey:
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. | |||
|
feedback
|
|
(I fail to understand the point of the dichotomy between SO and SU for such questions... Anyway:) Your question has already been answered, a few days later, on SO: ftplugins + local mappings/abbreviations/commands are the way to go. Regarding javac call, Just use %< to obtain the filename without the extension. A first correct mapping thus becomes:
But prefer instead to rely on the quickfix mode with:
| |||
|
feedback
|