I\'m trying to find the name of the file I\'m editing inside of Vim. So I can use it to map F5 to compile this file. Would of course be great if I could recognize
The other points are very useful. I would add that you probably want to use :p, to ensure that the file name is passed as a fully qualified path. Without it, Vim may pass it as a path that is relative to Vim's current path, which may or may not be the same path as the compiler uses. So one solution is:
nnoremap :!javac %:p
If you want to detect the file type automatically you could use AutoCommand
autocmd FileType java nnoremap :!javac %:p
autocmd FileType cpp nnoremap :!gcc %:p