Lots of people use a very huge config for vim. It makes me suck.
vim -u NONE
allows you to run an original version of vim, it's pretty useful especially temporarily working on other people's vim.
Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts
Sunday, September 14, 2014
Friday, August 15, 2014
Vim split window scrollbind
Sometimes, you want to make vim to scroll down two windows together (like in vimdiff).
:set scb
:set scrollbind
# toggle the option
:set scb!
Ref:
vim.wikia.com/wiki/Scrolling_synchronously
:set scb
:set scrollbind
# toggle the option
:set scb!
Ref:
vim.wikia.com/wiki/Scrolling_synchronously
Saturday, July 20, 2013
HIT2013 解題心得
今年因為一些緣故,所以無法到會場參加每年安全最大的盛會 hitcon
雖然一開始搶票的時候沒弄到,連幹了活X通幾聲
然而,幸運的在今年 PyCON 2013 中午看到 @crboy 小畢發噗,說也來寫個哀怨的對聯好了XDD
創意對聯
Cyberwar: in hack, we trust
Ticketwar: at midnight, the site crashed
橫批:Distributed Denial of Service
沒想到... 就拿到票惹XD
Anyway, 來寫心得文吧!XD
今年題目設計和以往又有些不同,多了很多 AppleScript/Obj-C 的 hacking, PE / .NET 逆向題目也不錯,.apk 也許也該來碰了...XD
各題首次破台者
媽我在這~~~._./
最終盤面
稍作整理然後轉成 binary
echo -n -e $(tr -d '[:space:]' | sed 's/../\\x&/g')
$ file new.bin
new.bin: PE32 executable for MS Windows (console) Intel 80386 32-bit

這個東西拿到 VM 底下就一隻該死的南瓜... Orz (而且還會唱歌www)
而且還需要用 upx 去個殼...
strings 結果:
字串都不是 key
IDA 看了很久也沒有想法,丟給隊友作,後來據說是解神奇的數學 (?
這題乍看之下要分析 JavaScript (小弟苦手...
而且還是 aaencode ゚ω゚ノ= /`m´)ノ ~┻━┻
不過... 其實秘訣就... 讓那段 code 動起來XDD
strings 結果:
字串都不是 key
IDA 看了很久也沒有想法,丟給隊友作,後來據說是解神奇的數學 (?
解!
這題乍看之下要分析 JavaScript (小弟苦手...
而且還是 aaencode ゚ω゚ノ= /`m´)ノ ~┻━┻
不過... 其實秘訣就... 讓那段 code 動起來XDD
chrome console 下,var foo = function {......}
foo();
就拿到 key 啦!還會有動畫XDDDD
Web 苦手,pass 給隊友 Orz
社交工程 pf ㄉㄉ也可以拿到 key
foo();
就拿到 key 啦!還會有動畫XDDDD
解!
Web 苦手,pass 給隊友 Orz
這題其實www
乍看之下 py2exe 要反解... 不過就...
unzip + vim 搞定XD
strings 出來的解和這邊一樣...
http://stuff.mit.edu/afs/sipb/project/hurddev/tb/libc/locale/C-identification.c
http://svn.haiku-os.org/oldhaiku/haiku/branches/old/wcsmbs/current/src/kernel/libroot/posix/glibc/wcsmbs/wcsmbsload.c
這個也殘念,exploit pdf 先丟反解把 pdf decode 成明碼
用和這邊 類似的作法,可是沒找到可疑的 JavaScript ...
Pass
隊友 TW1943 完成
rar fixnul.Ly
crack md5
Philippines
得意解!!!!!
PyCON.tw 2013 時,Orange 在 "駭客看 Django" 的議程上特別說過,Secret key 很重要,可以用來偽造 Cookie 達成許多不可思議的事情
Google 找攻略,這邊有詳細介紹這類的攻擊方式
首先 clone 這個 repo 下來
connback.py 改成自己的機器,做反彈 shell
然後
./exploit.py "1%idg#a2%byqh@l1wcv^3kc=e*($0v44(u-c^@bf_lz-@#essk" http://vuln-django.orange.tw
到處看看
./exploit.py "1%idg#a2%byqh@l1wcv^3kc=e*($0v44(u-c^@bf_lz-@#essk" http://vuln-django.orange.tw
到處看看
# cat ./app/key.txt
看到後底下回個 QQ ...
沒想到 12 分鐘後就 done 了XDDDD
解完這題很開心,一度名次還沒前面的說QQ
我解完 PWN500 後自己測試帳號是第四名XDD
Saturday, January 12, 2013
vim easter eggs
幾個有趣的 vim 彩蛋
Ref. http://vim.wikia.com/wiki/Best_Vim_Tips
生命、宇宙和萬物的答案 (梗如以上影片)
:help 42
尋找聖杯吧!
:help holy-grail
help!
:help!
修道院(?
:help map-modes
當用戶覺得無聊時
:help UserGettingBored
湯匙
:help spoon
神縮寫
:help showmatch
你需要灌木嘛
:Ni!
Ceci n'est pas une pipe
這不是一個 pipe
:help bar
Ref. http://vim.wikia.com/wiki/Best_Vim_Tips
生命、宇宙和萬物的答案 (梗如以上影片)
:help 42
尋找聖杯吧!
:help holy-grail
help!
:help!
修道院(?
:help map-modes
當用戶覺得無聊時
:help UserGettingBored
湯匙
:help spoon
神縮寫
:help showmatch
你需要灌木嘛
:Ni!
Ceci n'est pas une pipe
這不是一個 pipe
:help bar
Friday, November 23, 2012
bye bye, mouse!
丟掉滑鼠的方法...
awesome wm - next gerneration framework window manager for X
http://awesome.naquadah.org/
vimium - the hacker's browser
http://vimium.github.com/
w3m text-based browser # with mobile web pages
http://w3m.sourceforge.net/
turses - twitter client
http://turses.readthedocs.org/en/latest
rxvt-unicode - terminal emulator
http://software.schmorp.de/pkg/rxvt-unicode.html
ranger file manager
http://ranger.nongnu.org/
irssi - the IRC client of the future
http://www.irssi.org/
alsamixer
http://alsa.opensrc.org/Alsamixer
mplayer
http://www.mplayerhq.hu/design7/news.html
emacs - just another operating system(X
http://www.gnu.org/software/emacs/
vim - the ultimate editor
http://www.vim.org/
... lots of command line tools
Good keybord
FILCO ninja majestouch II
Sunday, September 23, 2012
vim - motion.txt
motion.txt 記載了 vim 裡面移動相關的主要功能,本篇文章挑幾個比較常見的介紹
motion.txt 介紹的內容 (本篇掠過後三章XD)
1. Motions and operators operator
2. Left-right motions left-right-motions
3. Up-down motions up-down-motions
4. Word motions word-motions
5. Text object motions object-motions
6. Text object selection object-select
7. Marks mark-motions
8. Jumps jump-motions
9. Various motions various-motions
operator
c change delete 然後進入 insert mode
d delete 毫無反應只是個 delete
y yank into register 複製
~ swap case 改大小寫
gu make lowercase 改小寫
gU make uppercase 改大寫
g? ROT13 encoding 凱撒加密
v virtual mode
V 基於行的 virtaul mode
Ctrl - V 基於方塊(矩形)的 virtaul mode
left-right-motions
h <-
l ->
0 行首
^ 行首非空白
$ 行尾
f{char} find char 向右找到 {char} 在本行的位置然後把游標移過去
F{char}
t{char} to char 移動到 {char} 之前一格
T{char}
up-down-motions
j down
k up
G 檔尾
gg 檔頭
word-motions
w 向前一個 word
e 向前一個 word 的尾巴
b 向後一個 word
object-motions
( 向前一個句子
) 向前一個句子
{ 向前一個段落
} 向前一個段落
text object 是 vim 裏面一個特殊的概念,用來說明一項操作的作用對象
"a" 代表 an object
motion.txt 介紹的內容 (本篇掠過後三章XD)
1. Motions and operators operator
2. Left-right motions left-right-motions
3. Up-down motions up-down-motions
4. Word motions word-motions
5. Text object motions object-motions
6. Text object selection object-select
7. Marks mark-motions
8. Jumps jump-motions
9. Various motions various-motions
operator
c change delete 然後進入 insert mode
d delete 毫無反應只是個 delete
y yank into register 複製
~ swap case 改大小寫
gu make lowercase 改小寫
gU make uppercase 改大寫
g? ROT13 encoding 凱撒加密
v virtual mode
V 基於行的 virtaul mode
Ctrl - V 基於方塊(矩形)的 virtaul mode
left-right-motions
h <-
l ->
0 行首
^ 行首非空白
$ 行尾
f{char} find char 向右找到 {char} 在本行的位置然後把游標移過去
F{char}
t{char} to char 移動到 {char} 之前一格
T{char}
up-down-motions
j down
k up
G 檔尾
gg 檔頭
word-motions
w 向前一個 word
e 向前一個 word 的尾巴
b 向後一個 word
object-motions
( 向前一個句子
) 向前一個句子
{ 向前一個段落
} 向前一個段落
text object 是 vim 裏面一個特殊的概念,用來說明一項操作的作用對象
"a" 代表 an object
"i" 代表 inner object
object-select
aw a word
object-select
aw a word
iw inner word
as a sentence
is inner sentence
ap a paragraph
ip inner paragraph
ab a () block
ib inner () block
aB a {} block
iB inner {} block
ap a paragraph
ip inner paragraph
a[ a [] block
a] a [] block
i[ inner [] block
i] inner [] block
a< a <> block
a> a <> block
i< inner <> block
i> inner <> block
Monday, September 10, 2012
vim 十字瞄準器
in your vimrc
set cursorline set cursorcolumn hi CursorLine term=none cterm=none ctermbg=none ctermbg=none hi CursorColumn term=none cterm=none ctermbg=none ctermbg=none au InsertEnter * hi CursorLine term=none ctermbg=darkblue au InsertLeave * hi CursorLine term=none cterm=none ctermbg=none au InsertEnter * hi CursorColumn term=none ctermbg=darkblue au InsertLeave * hi CursorColumn term=none cterm=none ctermbg=none
吃飽太閒無聊弄的XD
vim quickfix
其實很久以前就看過了,印像中高中看過(?
但是一直覺得沒有很好用就沒在用(炸
不過 vim 的這個功能主要是針對 C/C++
後來寫比較多 Perl / Python 就沒用了...
今天剛好再看到一次,就先筆記下來
:set makeprg=gcc\ -Wall\ -o\ %:r\ % # define how to compile the file
:make # compile the program
:cc # error message
:cn # next error
:cp # previous error
:cw # open the quickfix window
ref.
http://easwy.com/blog/archives/advanced-vim-skills-quickfix-mode/
Friday, June 29, 2012
vim tips: folding fun
本文參考自 : https://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun
介紹 vim 的 folding 技巧,也就是如何乾淨的把 code 折疊起來
首先,vim folding 指令都是由 z 開頭,我的記法是 zip the code
z 開頭的指令 zt zz zb 這三個很好用,順便提一下
功能是把游標目前所在的行捲到螢幕的 top / center / bottom
這在臨時上下捲動頁面半頁或是要邊寫 function 時很好用
vim 底下:h z 可以看到 folding 相關的指令 (這邊把其他不相干的刪減掉了)
BTW,最完整的教學在 :h fold.txt 裏面可以看到
zA zA open a closed fold or close an open fold recursively zC zC close folds recursively zD zD delete folds recursively zE zE eliminate all folds zF zF create a fold for N lines zO zO open folds recursively za za open a closed fold, close an open fold zc zc close a fold zd zd delete a fold zf zf{motion} create a fold for Nmove text zj zj 1 move to the start of the next fold zk zk 1 move to the end of the previous fold
看的懂英文應該基本上就知道這幾個要怎麼用了XD
最常用的是 zf + {motion}
像是 zf2j 可以向下折疊兩行 (zip folding 2 j),就跟你用 2j 在 vim 裏面往下移動兩行一樣
另外一種方法是在 normal mode 下 :N, M fold ,N M 是行數,把 N, M 行之間的 code 折起來
再來一種是 {Visual}zf 也就是用 visual 模式下選取要 folding 的區域,然後再用 zf 幫你折起來
zf 的 motion 也可以搭配 vim 的 text object 來使用,像是 zfa} 或是 zfa{ 可以向下或向上折疊一段落
當然,也可以搭配 searching 來找,zf/pattern 就是折疊到第一個你找到的 pattern
接下來是使用 folding 的方法
zo / zc 則是拿來 open/close folding 的
zO / zC 可以 打開/關閉 底下的子 folding
當然,za 和 zA 可以把 folding 當成電燈開關一樣,打開 folded 的區塊, fold 被打開的區塊
zr / zm 是將 fold level 開啟和關閉一層
zR / zM 是對所有的 fold level 作,也就是打開 / 關閉整個檔案裡所以的 folding
在被 folded 的 code 間移動有很快的作法, zj / zk ,如同你所想的,移動到 上 / 下個 folded 的 code
zd delete 掉游標所在的 folding
zE delete 所有的 folding
最後, vim 在處理被 folding 起來的區塊時,會把他當成像是一行文一樣,也就是說,可以對他做一行的操作,像是 dd 和 yy 等
Thursday, June 7, 2012
Editing remote files via scp in vim
之前看到有人在 plurl 上分享這則 vim tips
http://vim.wikia.com/wiki/Editing_remote_files_via_scp_in_vim
用法 vim scp://user@機器/絕對路徑
$ vim scp://remoteuser@server.tld//path/to/document
# 透過 ~/ 到 home 的相對路徑
$ vim scp://xatier@mydomain/~/foo.pl
# 同樣的也可以寫成這樣
$ vim scp://xatier@mydomain//home/xatier/foo.pl
其原理是透過先 scp 到本地 /tmp 後再用 vim 打開,存檔時會再 scp 回去
觀察信息可以看到
:!scp -q 'remote file' '/tmp/vRSFC24/0.pl'
:!scp -q '/tmp/vRSFC24/0' 'remotefile'
http://vim.wikia.com/wiki/Editing_remote_files_via_scp_in_vim
用法 vim scp://user@機器/絕對路徑
$ vim scp://remoteuser@server.tld//path/to/document
# 透過 ~/ 到 home 的相對路徑
$ vim scp://xatier@mydomain/~/foo.pl
# 同樣的也可以寫成這樣
$ vim scp://xatier@mydomain//home/xatier/foo.pl
其原理是透過先 scp 到本地 /tmp 後再用 vim 打開,存檔時會再 scp 回去
觀察信息可以看到
:!scp -q 'remote file' '/tmp/vRSFC24/0.pl'
:!scp -q '/tmp/vRSFC24/0' 'remotefile'
Wednesday, June 6, 2012
100 Vim commands every programmer should know
100 Vim commands every programmer should know
感謝 darkgerm 學長用心挑錯
一百個 programmer 應該知道的 vim 指令
http://www.catswhocode.com/blog/100-vim-commands-every-programmer-should-know
Since the 70′s, Vi is one of the programmer’s best friend. Nevermind you’re new to Vi or not, here’s a big list of 100 useful commands, organized by topic, which will make your coder life better.
原文錯誤很多 Orz
http://www.catswhocode.com/blog/100-vim-commands-every-programmer-should-know
Since the 70′s, Vi is one of the programmer’s best friend. Nevermind you’re new to Vi or not, here’s a big list of 100 useful commands, organized by topic, which will make your coder life better.
原文錯誤很多 Orz
我做了翻譯和更正
感謝 darkgerm 學長用心挑錯
====================================================
Basics 基本 :e filename 打開編輯(e) filename :w 存檔 :q 離開 :q! 離開但不存檔 Search 搜尋 /word 由上而下搜尋 word ?word 由下而上搜尋 word /jo[ha]n 搜尋 john 或 joan /\<the 搜尋以 the 開頭的字 /the\> 搜尋以 the 結尾的字 /\<the\> 搜尋 the 這個字 /\<....\> 找所有四個字母組成的字 /\<fred\> 找 fred 但不是 alfred 或 frederick /fred\|joe 找 fred 或 joe /\<\d\d\d\d\> 找四個數字 (長度為 4 的數字 )
/^\n\{\3\} 三個空行,有一個 magic 的寫法是 /\v^\n{3} (*) :bufdo /searchstr/ 搜尋所有開啟的檔案 Replace 取代 :%s/old/new/g 在本檔案(%) 取代(s) 所有(g) old 改成 new :%s/old/new/gc 取代所有時確認一下 c(Confirm) :2,35s/old/new/g 第 2 到第 35 行之間取代 :5,$s/old/new/g 第五行到檔案結尾 (EOF) 之間取代 :%s/^/hello/g 把每一行的開頭取代成 hello :%s/$/Harry/g 把每一行的結尾取代成 Harry :%s/onward/forward/gi 取代 onward 成 forward ,不管大小寫(i) :%s/ *$//g 刪除所有"trailing space" :g/string/d 刪除所有包含 string 的行 :v/string/d 刪除所有不包含 string 的行 :s/Bill/Steve/ 取代本行第一個 Bill 成 Steve :s/Bill/Steve/g 取代本行所有(g) Bill 成 Steve :%s/Bill/Steve/g 取代本檔案(%) 所有(g) Bill 成 Steve :%s/\r//g 刪除 DOS 換行 (^M) :%s/\r/\n/g 把 DOS 換行改成一般換行 (*)
:%s#<[^>]\+>##g 刪除 HTML 標籤但保留文字 (*) :%s/^\(.*\)\n\1$/\1/ 刪除重複兩次的行 Ctrl+a 游標所在的數字加一 Ctrl+x 游標所在的數字減一 ggVGg? 全文選取(ggVG) Rot13 加密 (g?) Case 大小寫 Vu 整行選取(V)改小寫 VU 整行選取(V)改大寫 g~~ 整行大小寫轉換 vEU 把字改成大寫 vE~ 字的大小寫轉換 ggguG 全文改小寫 :set ignorecase 設定搜尋時忽略大小寫 :set smartcase 設定搜尋時忽略大小寫除非有使用大寫字 :%s/\<./\u&/g 每一個字的第一個字母改大寫 :%s/\<./\l&/g 每一個字的第一個字母改小寫 :%s/.*/\u& 每一行的第一個字母改大寫 :%s/.*/\l& 每一行的第一個字母改小寫 Read/Write files 讀寫檔案 :1,10 w outfile 在 outfile 存 1 到 10 行 :1,10 w >> outfile 附加 1 到 10 行去 outfile :r infile 插入 infile 的內容 :23r infile 在 23 行插入 infile 的內容 File explorer 檔案瀏覽 :e . 打開檔案瀏覽器 :Sex 水平分割視窗並打開檔案瀏覽器 Sexplore (Split&Explore) (*) :browse e 指定的目錄裏打開瀏覽器並編輯選擇的文件 {only in Win32, Athena, Motif, GTK and Mac GUI} :ls 列出現在的 buffer :cd .. 回到上一層資料夾 :args 列出參數 (正在編輯的檔案列表) :args *.php php 檔 :grep expression *.php 回傳一個所有包含 expressoin2 的 .php 檔之列表 gf 開啟游標現在指向的檔案 Interact with Unix 跟 Unix 互動 :!pwd 執行 pwd unix 指令,然後回到 vi !!pwd 執行 pwd unix 指令,把結果插入到檔案 :sh 暫時開一個 shell $exit (在剛剛開的 shell 裡) 用 exit 指令回到 vim (其實用 Ctrl-D 也可以) Alignment 對齊 :%!fmt 對齊所有行 (外部指令) !}fmt 對齊所有在 {} 內的行 5!!fmt 對齊下五行 Tabs 分頁 :tabnew 開新分頁 gt 下一個分頁 gT 上一個分頁 :tabfirst 第一個分頁 :tablast 最後一個分頁 :tabm n tabmove 把當前分頁移到 n 的位置 :tabdo %s/foo/bar/g 在所有分頁執行指令 :tab ball 把所有有開的檔案放在一個 tab 裡 Window spliting 分割視窗 :e filename 在目前視窗編輯 filename :split filename 分割視窗並開啟 filename ctrl-w k 游標移到上面的視窗 ctrl-w ctrl-w 游標移到下一個視窗 ctrl-w_ 視窗最大化 ctrl-w= 視窗大小均等 10 ctrl-w+ 增加十行的大小 :vsplit file 垂直分割視窗 :sview file 分割視窗 (唯讀) :hide 關閉目前視窗 :only 關閉其他所有視窗 :b 2 打開 buffer 2 Auto-completion 自動補完 Ctrl+n Ctrl+p (在 insert mode) 補完字 Ctrl+x Ctrl+l 補完行 :set dictionary=dict 將 dict 設成字典 Ctrl+x Ctrl+k 字典補完 Marks 標記 mk 將目前位置標記為 k `k 把游標移動 k 標記 d'k 刪除所有 k 標記之前的東西 Abbreviations 縮寫 :ab mail mail@provider.org 定義 mail 是 mail@provider.org 的縮寫 Text indent 文字縮排 :set autoindent 設定自動縮排 :set smartindent 設定聰明縮排 :set shiftwidth=4 以四個 space 當作縮排大小 ctrl-t, ctrl-d 縮排/反縮排 (在 insert mode 下) >> 縮排 << 反縮排 Syntax highlighting 語法上色 :syntax on 打開語法上色 :syntax off 關閉語法上色 :set syntax=perl 設定特定語法
==================================================
**註**
Use of "\v" means that in the pattern after it all ASCII characters except '0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning. "very magic"
把 早期的 MAC 換行換成 windows 換行 windows 換行是 \r\n *nix 是 \n 早期的 MAC 是 \r 現在 MAC 底層是 BSD 所以也是 \n
有 dos2unix 可以轉
對這行 s/#/\//g XD
這個作法其實會有很多問題,例如如果 tag 中有換行就失效了
或是文字有 < > 也會出問題
引用 irc://irc.freenode.net/regex 的 title Do NOT use RegEx to parse HTML!
比較好的做法是用程式去 parse
Sexplore (Split&Explore)
還有 Vex 我覺的比較好用
Learn to speak vim
看到了一篇蠻有趣的文章
http://yanpritzker.com/2011/12/16/learn-to-speak-vim-verbs-nouns-and-modifiers/
節錄如下
Using vim is like talking to your editor in ‘verb modifier object’ sentences, turned into acronyms learn some verbs: v (visual), c (change), d (delete), y (yank/copy). these are the most important. there are others learn some modifiers: i (inside), a (around), t (till..finds a character), f (find..like till except including the char), / (search..find a string/regex) learn some text objects: w (word), s (sentence) p (paragraph) b (block/parentheses), t (tag, works for html/xml) there are others To move efficiently in vim, don’t try to do anything by pressing keys many times, instead speak to the editor in sentences delete the current word: diw (delete inside word) change current sentence: cis (change inside sentence) change a string inside quotes: ci” (change inside quote) change until next occurrence of ‘foo’: c/foo (change search foo) change everything from here to the letter X: ctX visually select this paragraph: vap (visual around paragraph) If you nderstand the verbs and objects you’re dealing with, you will soon realize that adding a new plugin and learning a new verb or noun exponentially increases your productivity, as you can now apply it in all the sentences you already know. It’s just like learning a language.
Friday, June 1, 2012
my vimrc
今天在噗浪上看到有人分享 github 上的這份 The Ultimate vimrc
順手又在我的 vimrc 添增幾筆有用的 settings
我的 vimrc 也是到處看別人的撇步和技巧
順便推一下 vgod 學長的 vgod'vimrc XD
以下分享我的 vimrc 設定
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just " /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime " you can find below. If you wish to change any of those settings, you should " do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten " everytime an upgrade of the vim packages is performed. It is recommended to " make changes after sourcing debian.vim since it alters the value of the " 'compatible' option. " This line should not be removed as it ensures that various options are " properly set to work with the Vim-related packages available in Debian. runtime! debian.vim " Uncomment the next line to make Vim more Vi-compatible " NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous " options, so any other options should be set AFTER setting 'compatible'. "set compatible " Vim5 and later versions support syntax highlighting. Uncommenting the " following enables syntax highlighting by default. if has("syntax") syntax on endif " If using a dark background within the editing area and syntax highlighting " turn on this option as well "set background=dark " Uncomment the following to have Vim jump to the last position when " reopening a file "if has("autocmd") " au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif "endif " Uncomment the following to have Vim load indentation rules and plugins " according to the detected filetype. "if has("autocmd") " filetype plugin on " indent on "endif " The following are commented out as they cause vim to behave a lot " differently from regular Vi. They are highly recommended though. "set showcmd " Show (partial) command in status line. "set showmatch " Show matching brackets. "set ignorecase " Do case insensitive matching "set smartcase " Do smart case matching "set incsearch " Incremental search "set autowrite " Automatically save before commands like :next and :make "set hidden " Hide buffers when they are abandoned "set mouse=a " Enable mouse usage (all modes) " Source a global configuration file if available if filereadable("/etc/vim/vimrc.local") source /etc/vim/vimrc.local endif " -- extend settings of vim ------------------------------------------------ "########################################################################### " multi-encoding setting "########################################################################### if has("multi_byte") "set bomb set fileencodings=ucs-bom,utf-8,cp936,big5,euc-jp,euc-kr,latin1 " CJK environment detection and corresponding setting if v:lang =~ "^zh_CN" " Use cp936 to support GBK, euc-cn == gb2312 set encoding=cp936 set termencoding=cp936 set fileencoding=cp936 elseif v:lang =~ "^zh_TW" " cp950, big5 or euc-tw " Are they equal to each other? set encoding=big5 set termencoding=big5 set fileencoding=big5 elseif v:lang =~ "^ko" " Copied from someone's dotfile, untested set encoding=euc-kr set termencoding=euc-kr set fileencoding=euc-kr elseif v:lang =~ "^ja_JP" " Copied from someone's dotfile, untested set encoding=euc-jp set termencoding=euc-jp set fileencoding=euc-jp endif " Detect UTF-8 locale, and replace CJK setting if needed if v:lang =~ "utf8$" || v:lang =~ "UTF-8$" set encoding=utf-8 set termencoding=utf-8 set fileencoding=utf-8 endif else echoerr "Sorry, this version of (g)vim was not compiled with multi_byte" endif "########################################################################### " Gerneral settings "########################################################################### " syntax highlighting syntax on " line number "set number " make tab = four spaces set expandtab set tabstop=4 set shiftwidth=4 " highlight search results and ignore case set hlsearch set ic " make < and > as a pair, useful in C++ set matchpairs+=<:> " don't do auto indent while pasting "set paste " automatically read the file again when it changed outside vim set autoread " always show current position (replace this with statusline) set ruler set showmode filetype plugin on filetype indent on "########################################################################### " color settings "########################################################################### " colorscheme colo pablo " using ':colo [tab]' to change colorscheme " number of colors 256 set t_Co=256 " change line (?) set colorcolumn=80 hi ColorColumn ctermbg=red set bg=dark "########################################################################### " statusline "########################################################################### set laststatus=2 set statusline=\ %F%m%r%h%w%=[%l,%3v]\ --%p%%--\ \ hi statusline ctermbg=darkblue "########################################################################### " key mappings "########################################################################### " F7 to close syntax high-lighting map <F7> :if exists("syntax_on") <BAR> \ syntax off <BAR><CR> \ else <BAR> \ syntax enable <BAR> \ endif <CR> " F9 to compile C/C++ files au FileType cpp map <F9> :!g++ -std=c++0x -Wall -Wextra -pedantic -Ofast % -lm -o %:r<CR> au FileType c map <F9> :!gcc -std=c99 -Wall -Wextra -pedantic -Ofast % -lm -o %:r<CR> " K to lookup current word in perldoc au FileType perl nmap K :!perldoc <cword> <bar><bar> perldoc -f <cword><CR><CR> " F8 to run the program (without file type) map <F8> :!./%:r<CR> " F5 to run a script map <F5> :!./%<CR>
Subscribe to:
Posts (Atom)