Very Basic Vim

You can edit /etc/vim/.vimrc for settings
origin mode, insert mode, quit mode

origin mode

main usage:
h,j,k,l for the moving
i for entering insert mode
for entering the quit mode

insert mode

just like the origin windows one

quit mode

:w for saving
:q for quitting

Makefile

本质:描述有向无环图
BASIC rule:
target file: dependent file
instructions

first example: hello world

1
2
3
4
5
6
7
8
9
hello:hello.o
    gcc hello.o -o hello
   
hello.o:hello.c
    gcc -c hello.c -o hello.o

.PHONY:
clear:
rm hello.o hello.S hello.i

a more complicated one: test

target: test
origin: program1.c program1.h program2.c program2.h main.c main.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 目标文件:test
# 现有文件:program1.c program1.h program2.c program2.h main.c main.h

test:program1.o program2.o main.o
gcc program1.o program2.o main.o -o test

program1.o:program1.c
gcc -c program1.c -o program1.o

program2.o:program2.c
gcc -c program2.c -o program2.o

main.o:main.c
gcc -c main.c -o main.o

.PHONY:
clean_all:
rm program1.o program2.o main.o

some skills

=: simplifying
TAR = test : TAR can stand for test
+=: adding
TAR += test1: TAR can not only stand for test, but also stand for test1
:=: always =
simplification of the example above: \

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
TAR = test
OBJ = program1.o program2.o main.o
CC := gcc

$(TAR):$(OBJ)
$(CC) $(OBJ) -o $(TAR)

program1.o:program1.c
$(CC) -c program1.c -o program1.o

program2.o:program2.c
$(CC) -c program2.c -o program2.o

main.o:main.c
$(CC) -c main.c -o mian.o

.PHONY:
clean_all:
rm $(OBJ)

%.o: any .o file
*.o: all of the .o file

1
2
3
4
5
6
7
8
program1.o:program1.c
$(CC) -c program1.c -o program1.o

program2.o:program2.c
$(CC) -c program2.c -o program2.o

main.o:main.c
$(CC) -c main.c -o mian.o

can be simplified to

1
2
%.o:%.c
$(CC) -c %.c -o %.o

$^: all dependent files
$@: all target files
$<: all first files of the dependent files

Basic GDB & Valgrind

a simple tool for debugging
see [[61C-P0-debug]] for more!

tmux

 a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal.

sessions

start

1
tmux

exit

1
exit

or ^D

create a session

1
tmux new -s <session-name> # seems not work!

split sessions

1
tmux detach

list sessions

1
2
tmux ls
tmux list-session

enter sessions

1
tmux attach -t 0

kill sessions

1
tmux kill-session -t 0

windows

split windows

1
2
tmux split-window # split up and down
tmux split-window h # split right and left

光标切换到上方窗格
$ tmux select-pane -U
光标切换到下方窗格
$ tmux select-pane -D
光标切换到左边窗格
$ tmux select-pane -L
光标切换到右边窗格
$ tmux select-pane -R
当前窗格上移
$ tmux swap-pane -U
当前窗格下移
$ tmux swap-pane -D

GitHub SSH in Linux

1
ssh-keygen -t ed25519 -C "your-email"

then enter twice (if you want to set up the password, ignore that)
your public key will be generated in /root/.ssh/id_exxxx.pub
using github, add the generated ssh key to your account, then OK

other useful informations

aptitude is a useful tool for handling the dependency in linux!