created February 3, 2006 · complexity intermediate · author Matt Zyzik · version 6.0
I use Vim for all text editing, even software development. At one point I stopped using IDEs. One major reason is that Vim can do all the major things I need from IDEs (tabs, file trees, greping, syntax highlighting, indentation, completion, "quickfix"ing, etc).
Still Vim needs plugins to do some IDE-like things that aren't built in.
One thing you might want is the vtreeexplorer script#184 plugin, which allows you to have a "file list" in a vertically split window. Another thing worth considering is the minibufexpl script#159 plugin, which will allow for tabs of all your files (works really well).
See function Kwbd in Deleting a buffer without changing your window layout which allows you to delete a buffer without actually closing the window. Also, below, I have a new, more complicated version of it. The below script will actually create a scratch buffer if there are no listed buffers left. The script, in addition, takes care of a small annoyance. Before, if you 1) open vim, 2) :e a file, 3) :bd, 4) :e the same file, then there will be two buffers listed (that file and a [no name] buffer). The following script ensures this doesn't happen.
Everything in this tutorial assumes the user does "set hidden".
Using this Kwbd function (:call Kwbd(1)) will make Vim behave like an IDE, or maybe even better.
"here is a more exotic version of my original Kwbd script "delete the buffer; keep windows; create a scratch buffer if no buffers left function Kwbd(kwbdStage) if(a:kwbdStage == 1) if(!buflisted(winbufnr(0))) bd! return endif let g:kwbdBufNum = bufnr("%") let g:kwbdWinNum = winnr() windo call Kwbd(2) execute "normal " . g:kwbdWinNum . "" let g:buflistedLeft = 0 let g:bufFinalJump = 0 let l:nBufs = bufnr("$") let l:i = 1 while(l:i <= l:nBufs) if(l:i != g:kwbdBufNum) if(buflisted(l:i)) let g:buflistedLeft = g:buflistedLeft + 1 else if(bufexists(l:i) && !strlen(bufname(l:i)) && !g:bufFinalJump) let g:bufFinalJump = l:i endif endif endif let l:i = l:i + 1 endwhile if(!g:buflistedLeft) if(g:bufFinalJump) windo if(buflisted(winbufnr(0))) | execute "b! " . g:bufFinalJump | endif else enew let l:newBuf = bufnr("%") windo if(buflisted(winbufnr(0))) | execute "b! " . l:newBuf | endif endif execute "normal " . g:kwbdWinNum . "" endif if(buflisted(g:kwbdBufNum) || g:kwbdBufNum == bufnr("%")) execute "bd! " . g:kwbdBufNum endif if(!g:buflistedLeft) set buflisted set bufhidden=delete set buftype=nofile setlocal noswapfile normal athis is the scratch buffer endif else if(bufnr("%") == g:kwbdBufNum) let prevbufvar = bufnr("#") if(prevbufvar > 0 && buflisted(prevbufvar) && prevbufvar != g:kwbdBufNum) b # else bn endif endif endif endfunction
Comments
For debugger integration, try http://clewn.sourceforge.net/
For when you're stuck with Visual Studio: see ViEmu at http://www.ngedit.com/viemu.html