目录
零、安装
0.Ctrl+Alt+T打开Terminal
1.先update
sudo apt-get update
2.安装gcc
sudo apt-get install gcc
3.安装g++
sudo apt-get install g++
4.安装vim
sudo apt-get install vim-gtk
5.编辑vimrc
sudo vim /etc/vim/vimrc
回车 进入文件
输入i 修改文件
按ESC 等待输入命令
输入:wq 保存并退出
1、自动补全括号:
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
function! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endfunction
2、使用鼠标定位光标:
:set mouse=a
6、撤销
u
7、回退
Ctrl+r
一、从编写到执行
1.编写
vim hello.cpp
2.编译
g++ -c hello.cpp
-c 是compile的意思,此命令将会生成 file.o 的目标文件。
3.链接
g++ hello.o -o hello.exe
-o 是指定生成的可执行文件名称(output)。若不给出,默认的名称为 a.out
上述两步通常也可以合在一起完成:
g++ hello.cpp -o hello.exe
4.执行
必须要给路径名
./hello.exe