• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content




A small presentation I prepared for the basics of vim, gcc and gdb.

A small presentation I prepared for the basics of vim, gcc and gdb.



Total Views
Views on SlideShare
Embed Views



1 Embed 4

http://www.slideshare.net 4



Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Basics Basics Presentation Transcript

    • Topics
      • Vim
      • Programming in C using gcc
      • Using gdb-GNU Debugger
      • Shell Scripting
    • Basics
      • Different editors in GNU/Linux
      • Vim-Vi Improved
      • Emacs
      • Gedit
      • Kate
      • nano
      • Many more....
    • Why Vim?
      • Simple to use
      • Has all the features that must be there in a basic editor
      • Unlimited undo
      • Syntax colouring
      • Visual selection
      • Split windows
      • Also has a GUI interface - Gvim
      • Many more......
    • Vim Basics
      • Start vim --- vim test.c
      • Open multiple files using -o and -O attributes
      • Insertion
      • Deletion
      • Dw to delete a word from the cursor
      • Cw to change a word from the cursor
      • Dd and cc to delete & change a line respectively
      • Esc to cancel your commads
      • Replace
    • Vim Basics
      • Playing with the cursor
      • Use normal arrow keys or h,j,k,l to move the cursor left,down,up,right.
      • Ctrl-f and ctrl-b for page down and page up.
      • 1G, nG, G to move to first, nth and last line.
      • 0 or ^ and $ for start and end of a particular line.
      • w and e for moving to start of next word and end of next word and b for moving to the previous word.
      • ( and ) for start and end of a sentence and { and } for start and end of paragraph.
      • H, M and L to move the cursor to the top,middle and bottom of the screen.
    • Vim basics
      • Some more short-cuts to edit
      • Yy and yw to yank a line and a word
      • p to paste
      • Adding a number in front of the command repeats the command so many times, example, 12yy, 3i
      • Visual Mode
      • v, V and Ctrl-V for visual mode of a character, line and block respectively
      • d-delete ,y-yank,U-convert to uppercase,u-convert to lowercase, ~ -togle,<-unident ,> - ident
      • Undo the last change using 'u' in normal mode
    • Vim Basics
      • Search for a word using '/', n and N to get next and previous match
      • Search and replace using %s/old/new/gc
      • %: the range of whole file, can replace with a range of lines like (2,50)
      • s: substitution
      • old: old pattern to match
      • new: new pattern for replacement
      • g: global
      • c: confirm for every replacement
      • Split and vs for horizontal and vertical split
      • '!' can be used to execute commands
      • Ctrl-p in insert mode shows suggestions in autocomplete
    • Gcc basics
      • GCC developed by Richard M Stallman as a part of GNU Project
      • First release in 1987 and in 1992, second release feature to compile
      • c++ was added.
      • Features of GCC
      • It is a portable compiler, runs on most platforms including microcontrollers,DSPs and 64-bit CPUs
      • GCC is not only a native compiler but also a cross compiler and hence can produce executables for a different system than itself. It can compile itself.
      • It has multiple language front-ends for parsing different languages.
      • It has a modular design, hence allowing new languages and architectures to be added very easily
      • GCC is completely free software!!!!
    • Gcc Basics
      • How does gcc compile the source code into executable?
      • Preprocessing (to expand macros)
      • cpp hello.c > hello.i (for c++, it is .ii)
      • Compilation (from source code to assembly language)
      • gcc -Wall -S hello.i (-S instructs the compiler not to create the object file)
      • Assembly (from assembly language to machine code)
      • as hello.s -o hello.o (calls to external functions are left undefined to be filled later by the linker)
      • Linking (to create the final executable)
      • gcc hello.o
      • Run ./a.out to get ”Hello, World!”
      as hello.s -o hello.o
    • Gcc basics
      • In short, to compile the source code use
      • gcc -Wall hello.c , the executable is stored as a.out
      • or
      • gcc -Wall hello.c -o hello , the executable is stored as hello
      • To execute the executable
      • ./a.out or ./hello
    • Gdb basics
      • Normal DeBugging Techniques
      • Insert lots of printf statements.
      • Insert lots of assert statements.
      • Use a debugger to find out where your code went wrong.
      • Uses of Gdb
      • Used to examine the code, line by line and check the status variables.
      • Very important in situations like segmentation faults
    • GDB basics
      • Basic commands
      • Run
      • Display and print
      • Break and ignore and disable
      • Backtrace
      • Next and step
      • Continue
    • Thank you T. Vignesh Prabhu (tvigneshprabhu@gmail.com)