Tip #264: F5 Compile and Run, F8 Compile (ala Visual Studio)
tip karma |
Rating 7/10, Viewed by 1185
|
created: |
|
June 22, 2002 9:18 |
|
complexity: |
|
basic |
author: |
|
Tadghe Danu |
|
as of Vim: |
|
6.0 |
I love vim, it's my default editor on my Sun, Windows, Linux and *BSD boxen. That said, I hate having to flip windows to compile while doing the write->compile->debug loop.
If you're used to Visual Studio and the ability it has to just hit F5 to compile and run the current file or F8 to compile or step through the code you'll appreciate this...
This is my Windows version of this scriplet/tiplet. For other platforms, you'll want to change the IF ELSE loops. You should actually never see the "Unsuccessful" message from the compile/run loop unless the compiler completely bombs out. This is from my _vimrc...
map <F5> :call CompileRunGcc()<CR>
map <F8> : call CompileGcc()<CR>
func! CompileRunGcc()
exec "w" "Save the file
exec "!gcc % -o %< && cr 10 && IF EXIST %<.exe (%<) ELSE banner -c = Compile Unsuccessful "
exec "i" "jump back where we were
endfunc
func! CompileGcc()
exec "w"
exec "!gcc % -o %< && IF EXIST %<.exe (cr 5 && banner -c # Success) ELSE banner -c # Compile Unsuccessful "
exec "i"
endfunc
<<color active line |
Fast help in full window >>
Additional Notes
|