I'm sure many vim users wonder the same thing. They may also wonder how people can develop using tools that are coupled to each other rather than choosing the various development tools as they see fit.
In any event it's not either/or. The times I've needed Netbeans, for example, I use vim for actual code editing and the IDE for assorted handy click-here-to-run things.
This was my problem when I started with Vim. But then I learned to love GDB and other command-line development tools. At first it seemed a bit archaic to me, a Visual Studio user at the time, but when I got a hang of it, I stopped missing IDE debugging. Now I'm at the point where I feel crippled trying to develop in an IDE (no split windows, to vim-style macros, inefficient use of screen space, constantly have to switch between mouse and keyboard).
For example, GDB can be scripted, so you can repeat debugging sessions, your entire debugging session is printed, so you can always go back and see the history of changed values. It supports pretty-printing STL containers and you can add your own pretty-printers in python.
There are a lot more to these tools than you can discover by poking and trying things like you would with an IDE, they have a steeper learning curve, but I wouldn't dismiss them immediately as a waste of time.
:bufdo %s/foo/bar/g | update
Although I wouldn't knock `bash command madness' for this sort of task. :)The Unix shell is pretty much designed for advanced text manipulation across files. E.g., to replace all instances of foo with bar in HTML files, recursively:
$ find . -name '*.html' -exec perl -i -lpe 's/foo/bar/g' {} \;
vim and the shell are not so far apart and complement each other well, so it pays to understand them both.$ deep replace "foo" "bar" "*.html"
So you get in the habit of annotating test tweaks & debug prints with:
printf("DNCI x is %d\n", x);
I use gdb as well, but sometimes dumping data directly is all you really need.
If you need breakpoints, watchpoints, and a GUI to click around in, your code is too complicated and unmaintainable, which is probably why you need a debugger in the first place.
Couple live autopsy with live edit-and-continue and you've got a recipe for a considerably more effective way of debugging code.
And "your code is too complicated and unmaintainable if you need a debugger" is preposterous on its face if you've ever...oh, I don't know...written a driver? Or any other remotely complex (you're conflating complicated and complex) task with a significant number of interlocking parts? (Hell, one could just as easily say that your code is too complicated and unmaintainable if you're barfing print statements all over the place.)
With test cases and print statements, starting over is free. If you need more information, edit the code to give it to you and re-run.
Getting a debugged program back to the desired state is, in my experience, difficult even with an automatic test. Not only does the program state have to be right, but so does the debugger state. Without the debugger, you have half the state to bother with.
So, yes, your nails may be straight, but your chosen (regressive) technique leaves you with no way to know if they're straight and with only the option of pounding harder and harder if the nail doesn't go in the first time. Enjoy!
If you debug without knowing what you're debugging and just looking for getting it running, it sounds like you're the one doing the shotgun-programming/debugging, separate debugger or not.
So, yes. I use a debugger, so that I can spend some time at home too. Because as nice as the office is, it's summertime, and there's beer in my fridge.
Back when I was seventeen and staying up all night writing a video game engine though, I definitely would have been onboard with the whole print debugging idea.
But again, I must be wrong because I'm doing it different, right? So the only option can be that I'm too young, don't know what I'm talking about, or just lack experience in general, right? There couldn't be a possible way that someone else uses a different solution that works just as fine for them, right?
Considering that I never said "Don't use a debugger." only that "I don't need a debugger", you guys seem pretty worked up considering that you're claiming you're the more relaxed one.
It's a tool, don't take it personally that I have a different method that works. It doesn't invalidate yours. At least not in my view.
Because if you're leaning on print statements in absence of appropriate tooling, I can understand that. When the tooling is available, however, I am skeptical of claims as to enhanced productivity or any other positivity coming from it.
There's a debugger, there's a REPL, and in general lots of tools which I use if I see the need (the NYTProf profiler would be one). Using a debugger in this scenario (with an interpreted language) just doesn't give me any enhanced productivity over what I'm doing now.
What does visual studio? Show the value of variables in separate windows as the code runs? Yes, the perl debugger can do that. You can also inject code and poke the entire program state.
The perl debugger is a perl function that is called for every line and every subroutine entry. Use that to build whatever tool you want, and good luck finding that in Visual Studio.
The second option is easier. You obviously remove them once your understanding (and tweaking) of the code leads to a passing test.
http://morganpyne.com/img/hacks/debugging-php-with-vim-and-x...
There are several articles out there on using vim as a fully-fledged IDE and setting up interactive debugging: http://www.koch.ro/blog/index.php?/archives/63-VIM-an-a-PHP-... http://tech.blog.box.net/2007/06/20/how-to-debug-php-with-vi... http://colonelpanic.net/2010/08/debugging-php-in-vim-using-v...
Note that these are for PHP development, but I'm sure some rummaging would uncover suport for whatever langugages you work in.
On the one hand, when developing for a new platform or language, you spend some extra time tweaking on VIM, rather than being able to use the platform developers Eclipse GUI immediately. On the other hand, I've found that being exposed to the command line tools with all their arguments, you are more able to fix problems and automate tasks.
Nothing beats vim for grunting through a pile of code that needs cleaning up. Just set up your IDE and vim to autoload when it detects changes.
My workflow generally goes Edit in vim -> check IDE for syntax errors -> Run/Debug -> repeat.