Basic operation of VIM text editor and basic usage of GCC and GDB

Source: Internet
Author: User
Tags prev gdb debugger

Vim test.c +24 opens and navigates to 24 rows

Command mode

1. Edit mode

H Left

J Down

K Up

L Right

I input insert

Gg=g can be indented in the first line

YY copy

P Paste

R Replacement Mode

R replaces the current position, back to command mode

DD Delete When moving forward

3DD Delete cursor below 3 lines

U undo

: line number is transferred to the corresponding row

J Stitch the next line to the end of the previous line

$ line end of the current line

0 or ^ The beginning of the current line

W jumps to the next word

B Jump to the previous word

Skip to next empty line

{Jumps to the last empty row

Press% on {or} to jump between the two

DW is removed from the cursor position to the end of the current word

DB removed from cursor position to current word header

X Delete one character

K or 3K can jump to its help manual for system functions or library functions

V Visualization (after JK operation x delete y copy) only row is selected

Ctrl + V block Visualization (you can select characters)

/Find (n next n prev)

? Word lookup (n next n prev)

2, the last line mode (:)

: W Save

: Q exit

: Set NU Displays line number

: No Nu Cancel line number

: 50,59s/old content/new content/g 50-59 lines of all old content replaced with new content (don't g replace the first occurrence of the old content on each line)

:%s/old content/new content/g full text replacement

: VSP file name Vertical split screen

: SP file name horizontal split screen

: Q exit

: R imports another file to the cursor location

CTRL+WW Jump to another screen

Gcc–e (preprocessing)/-s (assembly)/-c (connection)/-v (show compilation process) file name-O (rename)

GCC internal call CC1 compiler as assembler COLLECT2 linker

Strip the executable file name to thin the code

LDD executable to see which dynamic libraries are used by the program

GDB Debugger (gcc file name –o Execute file name-G)

List (l) line number display source code

Break (b) Line number/function name plus breakpoint

Info Break (i B) View breakpoint information

Run (R) executes

Next (n) stepping without entering the function

Print (p) printing variables

Whatis variable name view variable type

Delete (d) Breakpoint number remove Breakpoint

b if i==9 set a breakpoint when the condition equals 9

Step (s) enters function call

Finish Exit Function

Breaktrace (BT) view function call stack

Processing segment error-generates a core file that appears in the first few lines of error:

    1. Gcc–g
    2. Ulimit-c Unlimited
    3. ./a.out
    4. GdB./a.out core.****

Makefile

Target: Dependent files

tab command

The second way

$^ on behalf of all dependent files [email protected] on behalf of the target file

The Third Way

%.o:%.c

Gcc–c $^-o [email protected]

You can write the clean function in makefile, use make clean

. Phony:clean keep clean up to date

OBJS=MAIN.O \

Plane.o

Clean

RM–RF $ (OBJS) Here's objs is the previous definition variable

1, in scanf "%*c" is to read and discard the character, for reading discarded newline characters

or "(space)%c" This action can ignore whitespace characters before the character

or "%[^;%*c]" This operation can set the characters you want to read, which is the input format (do not get a semicolon, such as a database)

2. The memory buffer will output the contents of the buffer in the following 5 cases

\ n

scanf

Exit

Kernel buffer Full

Fflush (STDOUT)

3, printf output to the screen

fprintf Output to File

Sprint output to Array

Linux Read Elf file

Readelf–h (head)/-a (All)

See Assembly code for ELF files

Objdump-ds

Basic operation of VIM text editor and basic usage of GCC and GDB

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.