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"