Hi,
Vi (vim, actually) is 'just' an editor. There's no standard feature that debug's program X's code.
You can extend Vim to include such a feature. Create your own code snippet to do just that (or go on-line and search for one). Here's one that compiles gcc code and runs it, while still inside vim:
Code:
" -----------------------------------------------------------------------------
" Compile (gcc) and run written code
map <F4> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc % -o %<"
exec "! ./%<"
endfunc
Add the above to your .vimrc and, using the F4 function key, your code is compiled and run (or errormessages appear and it won't run

).
This will only compile the gcc code when pressing F3:
Code:
" -----------------------------------------------------------------------------
" Compile (gcc) written code
map <F3> : call CompileGcc()<CR>
func! CompileGcc()
exec "w"
exec "!gcc % -o %<"
endfunc
In general people will exit vim (or open a second terminal / use ctrl-z), run the program (after saving it) see what goes wrong, go back to vim, change code etc etc.
Depending on the language you are programming in and how often you program you could start looking for a specialized editor for that specific language. But vim will do nicely most of the time.
Personally I do all my programming in vim.
Hope this clears things up a bit.