Programmer guidelines -A brief introduction
Introduction
I have a basic document, which briefs about linux commands, Vim editor, Using vim for browsing C/C++ code and GDB. I thought that rewriting tutorials won't help. Instead I have mentioned how to go about, and specified the seemingly correct references. I'll update whenever possible.
Linux Commands
There are many linux commands, which you should be knowing. I'll
prioritize and add them. I dont want to explain in detail, instead read
the man pages.
find:
Search for files in a directory, for example:
> find . -name sort.c
Search for file "sort.c" in current directory (See dot)
> find src -name "*.c"
Search for filenames with .c extension in "src" directory.
Note: You can use pattern matching to search for files.
grep:
Editors
Vim is
today one of the two most popular editors for programmers and users of
Unix-like operating systems, alongside Emacs.
Vim
is said to have a steep learning curve, meaning learning is slow
initially but once the user gets a grasp of the basics they progress
quickly and their editing becomes more efficient. To facilitate this
there's the vim tutorial for beginners, usually invoked by typing
"vimtutor" on the Unix command line or clicking on the Vim tutor icon
on the Windows desktop. There's also the Vim Users' Manual that goes
into depth about the basic and more advanced features of Vim which can
be read by typing ":help
user-manual" within Vim.
New
users should also learn how to navigate and understand the conventions
of the Vim help system by reading the main help file by
typing ":help" without any arguments.
Learn the basics: Instead of reading the text (boring!) you can use the vimtutor to learn your first Vim commands. This is a 30 minute tutorial that teaches the most basic Vim functionality hands-on.
On Unix
and MS-Windows, if Vim has been properly installed, you can
start it from the shell:
> vimtutor
This will make a copy of the tutor file, so that you can edit it
without
the risk of damaging the original.
Further: It takes time to master vim. You have to learn gradually, build up from the basics, and apply the basics to create complex commands. Knowing regular expressions will help a lot to enhance searching and substitution. You can refer to cheat sheets available on net. But don't use them blindly. Try to understand what is mentioned then apply it .
Using
vim as a programmers Editor: Go through these links:
--
-
- Introduction to Programming in C/C++ with Vim http://www.justlinux.com/nhf/Programming/Introduction_to_C_Programming.html -
- A detailed help on using ctags (Browse through program sources) http://www.vim.org/tips/tip.php?tip_id=94
Summary:
Create tags file for your project source tree.cd <SrcDirectory> #cd to the parent dir where you have the src code
ctags -R #create the tags file
vim <filename> #open the file you want and start using tags.
Note: Always see that vim can locate the tags file. You can either do it by opening vim in the directory where tou have the tags file, or you can set the tags option from vim. (eg:- :set tags+=). See help for more details. You can also run vim -t
Links
http://www.networkcomputing.com/unixworld/tutorial/009/009.html - A nice vim tutorial. Read this only after doing vimtutor. http://www.vmunix.com/~gabor/vi.html - A vi quick reference. http://www.vim.org/ - Central place for vim community.
There are lots of tips and scripts available. See the (most viewed/top rated) tips to start with.
Google will give you thousands of links to other references.
GDB
RMS's gdb Debugger Tutorial: This
is gdb tutorial
explaining only the essentials. Try it out using examples. Two
examples are given at the end of it.
Once you get hands on you can refer the FSF's gdb refernece manual for more details, or read the info pages (info gdb).
- http://sources.redhat.com/gdb/current/onlinedocs/gdb_toc.html
- http://sources.redhat.com/gdb/current/onlinedocs/gdb.pdf.gz
- zip file
Links
http://users.actcom.co.il/~choo/lupg/tutorials/debugging/debugging-with-gdb.html
- Another basic gdb tutorial.
Note:
You may use larger projects which use scripts and makefiles to compile
your the project (Instead of just gcc -g). You may have to enable
relevant
debugging flags while running the configure scripts/makefiles in order
to debug the programs. There are other debugger apart from gdb
which works on different platforms; dbx on Unix, MS Visual Studio
debugger on Windows platform to name a few.