vim配置
进行配置的时候在终端输入命令行vim .vimrc
,在里面写vim的配置文件
vimrc
set nu "显示行号
set ai "ai是autoindent的简写,启动自动缩进
"set cin "cin是cindnet的简写,使用C语言格式的自动缩进
set hls "hls是hlsearsh的简写,启动搜索高亮
set ts=4 "ts是tabstop的简写
set sw=4 "sw是shiftwidth的简写,写set cin后用
set mouse=a "可以使用鼠标
color ron "color是colorscheme的简写
"ino ' ''<esc>i
"ino " ""<esc>i
"ino ( ()<esc>i
"ino [ []<esc>i
"ino { {}<esc>i
"ino {<cr> {<cr>}<esc>O
"括号补全,ino是inoremap的简写
map! jk <esc>:w<cr>
"进入普通模式并保存
"map! jl <end>
"map! jo <home>
"个人喜好,将比较远的键映射一下
"map! <C-h> <left>
"map! <C-j> <down>
"map! <C-k> <up>
"map! <C-l> <right>
"映射方向键(<C-h>表示Ctrl+h),这个可能用不习惯,可以不用
"map! <F5> <esc>:w<cr>:!g++ % -o %< -std=c++11 && time ./%< < IN<cr>
"map! <F7> <esc>:w<cr>:!g++ % -o %< -g && gdb %<<cr>
"map! <F6> <esc>:w<cr>:!python3 %<cr>
"map! <F9> <esc>:w<cr>:!cat %<cr>
map <F5> :w<cr>:!g++ % -o %< -D Shawk -std=c++11 -O2 && time ./%<<cr>
map <F7> :w<cr>:!g++ % -o %< -D Shawk -std=c++11 -g && gdb %<<cr>
"map <F6> :w<cr>:!python3 %<cr>
map <F9> :w<cr>:!cat %<cr>
"按F5进行编译运行cpp , time 可以显示运行时间(ms), < in 表示从 in 中读入
"按F6运行python代码
"按F7进行调试
"按F9可以将文件打出来,方便复制到系统剪切板
autocmd BufNewFile *.cpp exec ":call SetTitle()"
func SetTitle()
if &filetype == 'cpp'
call setline(1,"#include <cstdio>")
call append(line("."), "")
call append(line(".")+1, "using namespace std;")
call append(line(".")+2, "const int N = 1;")
call append(line(".")+3, "")
call append(line(".")+4, "int read(int x = 0, int f = 1, char c = getchar()) {")
call append(line(".")+5, " for (; c < '0' || c > '9'; c = getchar()) if (c == '-') f = -1;")
call append(line(".")+6, " for (; c >='0' && c <='9'; c = getchar()) x = x * 10 + c - '0';")
call append(line(".")+7, " return x * f;")
call append(line(".")+8, "}")
call append(line(".")+9, "")
call append(line(".")+10, "int main() {")
call append(line(".")+11, "#ifdef Shawk")
call append(line(".")+12, " freopen(\"in\", \"r\", stdin);")
call append(line(".")+13, "#endif")
call append(line(".")+14, "}")
endif
endfunc
一些不在我的配置文件的东西
-
set et
et是expandtab的简写,制表符将由空格代替 -
set noswapfile
:不产生.swap文件 -
tabstop
:制表符的长度 -
shiftwidth
:自动缩进的长度 -
colorscheme ron
: 主题选用ron(我个人比较喜欢这个)
关于键盘映射(map)
-
:nmap 在普通模式(Normal)下映射
-
:vmap 在可视化模式(Visual)下映射
-
:omap 在运算符模式(Operator Pending)下映射
-
:imap 在插入模式(Insert Only)下映射
-
:cmap 在命令行模式(Command Line)下映射
-
:map 相当与1,2,3和起来
-
:map! 相当与4,5和起来
-
:inoremap 是在插入模式下不递归的映射
gedit配置
首先要在首选项里开启外部工具的插件
Run
#!/bin/sh
fullname=$GEDIT_CURRENT_DOCUMENT_NAME
name=${fullname%.*}
gnome-terminal -x bash -c "rm $name; make $name; time ./$name < in; read"
Gdb
#!/bin/sh
fullname=$GEDIT_CURRENT_DOCUMENT_NAME
name=${fullname%.*}
gnome-terminal -x bash -c "g++ $fullname -o $name -g; gdb $name; read"