What is Your C Development Environment like?
Say I want to start looking at the source of a C project. First thing I do is highlight all the .c/.h files in the folder (ctrl + click and so on..), right click, select "open all with GVim". The script opens all .c and .h files in GVim in separate tabs each. After that, I resize the GVim window to leave some space for a terminal to run make/gcc/gdb/git etc. At this point, I'm ready to look at some code.
Browsing through code is not easy mainly because of the tabs. In this project that I'm looking at, there are 10+ files and I know that's not even a lot. I have to keep hitting 'gt' or 'gT' if I want to go to a certain .c or .h file and it's a nightmare if you have 10+ tabs open.
So, HN what is your environment or workflow like when coding in C? Any tips on how I can make my environment better?
Here's my environment right now:
Laptop 15.6" screen Ubuntu 10.04 GVim (NerdTree, Taglist, ctags) Terminal for (gcc, gdb, make, git)
GVim and Terminal are side by side.
8 comments
[ 3.3 ms ] story [ 27.3 ms ] threadlibstdc++.so.6 or something similar
on windows its in visual studio 2008, mac its xcode 4.x
other than that stuff i don't worry too much about detail and focus on making great programs that make me $
As lukesandberg points out, there's no reason to have 10+ files open at once. Work on one thing at once and only open up files when you're working on them or need to check something (e.g., "what order did I put the parameters to that function").
You can have a shell in an Emacs buffer, but I could never really get used to that. Instead, I use Tilda to have a Quake-style console that I can show or hide as I need.
- learn to open files from Vim with :e and tab completion
- learn to use buffers effectively, the :b command with tab completion is particularly useful to switch between buffers
- CRTL-0 / CTRL-I to go back and forth between cursor positions
- for C/C++, a.vim is a plugin that allows you to switch quickly between header and implementation
- learn to use make from Vim with :make, it will take you to the first compilation error and open a quickfix window that you can use to go to other errors (can be configured to compile other languages than C/C++)
- try ack, a better grep, very useful to search source code, there's a Vim plugin to integrate it
- if you have a lot of files and directories in your project, try the Command-T plugin
- for git, the Fugitive plugin can also be helpful (screencasts at http://vimcasts.org/)
I'm also a fan of TextWrangler on the Mac for its basic file sidebar for quickly switching, but its still a bit tougher on big projects, having only a "flat" view of your files.