2013年9月6日 星期五

更新.vimrc

~/.vimrc.html
 1 set nocompatible
 2 filetype off
 3 set rtp+=~/.vim/bundle/vundle/
 4 call vundle#rc()
 5 
 6 "let Vundle manage Vundle
 7 "required! 
 8 Bundle 'gmarik/vundle'
 9 Bundle 'Shougo/neocomplete.vim'
10 Bundle 'Shougo/vimproc.vim'
11 Bundle 'Shougo/vimshell.vim'
12 Bundle 'mbbill/echofunc'
13 
14 " Disable AutoComplPop. 
15 let g:acp_enableAtStartup = 0
16 " Use neocomplete.
17 let g:neocomplete#enable_at_startup = 1
18 " Use smartcase.
19 let g:neocomplete#enable_smart_case = 1
20 " Set minimum syntax keyword length.
21 let g:neocomplete#sources#syntax#min_keyword_length = 3
22 let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
23 
24 " Define dictionary.
25 let g:neocomplete#sources#dictionary#dictionaries = {
26      \ 'default' : '',
27      \ 'vimshell' : $HOME.'/.vimshell_hist',
28      \ 'scheme' : $HOME.'/.gosh_completions'
29 \ }
30 " Define keyword.
31 if !exists('g:neocomplete#keyword_patterns')
32     let g:neocomplete#keyword_patterns = {}
33 endif
34 let g:neocomplete#keyword_patterns['default'] = '\h\w*'
35 
36 set number
37 set showcmd
38 set showmatch
39 set hlsearch
40 set incsearch
41 set sw=4
42 set ts=4
43 syntax on
44 filetype indent on
45 filetype plugin on "~/.vim/syntax "omni-complete ~/.vim/autoload ^x^n
46 set smarttab
47 set sidescroll=1
48 set guifont=Inconsolata\ Medium\ 14
49 set guifontwide=YaHei\ Mono\ 14
50 set laststatus=2
51 set statusline=%F%m%r%h%w\ [%{&ff}]\ [%Y]\ [%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ [ASCII=\%03.3b]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]\ %=[%{GitBranch()}]
52 set backspace=2
53 set clipboard=unnamedplus
54 set autoindent
55 set smartindent
56 set cindent
57 "set spell
58 set encoding=utf-8
59 set makeprg=
60 set smartcase
61 set ruler
62 set cursorline
63 colors koehler
64 if has("gui_running")
65 else
66     set t_Co=16
67     "hi CursorLine cterm=NONE ctermbg=DarkGray ctermfg=NONE guibg=NONE guifg=NONE
68     hi CursorLine cterm=bold ctermbg=black ctermfg=NONE guibg=NONE guifg=NONE
69 endif
70 set fileencodings=ucs-bom,utf-8,euc-jp,cp936,big5,gb18030,euc-kr,latin1
71 set guioptions=aegimrLt
72 autocmd BufNewFile,BufRead *.mip :set syntax=mips
73 autocmd BufNewFile,BufRead *.S :set syntax=mips
74 if has("gui_running")
75 set langmenu=zh_TW.UTF-8
76 source $VIMRUNTIME/delmenu.vim
77 source $VIMRUNTIME/menu.vim
78 language messages zh_TW.utf-8
79 endif
80 
81 "let Tlist_Use_Right_Window=1                 " 在右側窗口中顯示
82 let Tlist_File_Fold_Auto_Close=1             " 自動摺疊 
83 let Tlist_Sort_Type = "name"
84 let Tlist_Show_One_File = 1
85 
86 let g:LargeFile=10
87 "let g:EclimTaglistEnabled=0
88 set csprg=gtags-cscope " use fake cscope
89 set cst "use cscope to get tags
90 cs a GTAGS . -C
91 "au BufWinLeave ?* mkview
92 "au BufWinEnter ?* silent loadview

2013年6月14日 星期五

coding的好朋友 -- tag

  當需要trace一個比較大的project時, 要如何正確找到function和variable的definition呢?

還在使用grep嗎?那就嚴重落伍了.

下面介紹三個產生tag的tool

1. EXUBERANT Ctags
http://ctags.sourceforge.net/
這個是最常用, 如果有使用Vim的人一定會知道的command (Ctrl + ] )
這個command可以幫你快速跳到definition這個後面就是使用ctags產生出來的tag list.
另外, 雖然一開始是為了C發展出來的tag, 但現在已經發展到支援許多語言格式, 如常見的java, python等等都有支援, 而且正確度極高.

2. Cscope
http://cscope.sourceforge.net/
上面說到ctags可以快速幫你找到function definition, 但如果是要找function caller的時候就不是這麼方便了.
這個時候就可以使用Cscope, Cscope能夠與Vim完美整合, 在Quick Fix Window裡顯示出所有可能的function caller的位置.
但Cscope有一個致命的缺點就是只有在C語言下表現完美, 在C++與Java裡都只是堪用而已, 準確度較低.

3. Gtags
http://www.gnu.org/software/global/
最後一個介紹的是Gtags, Gtags的曝光率比較低,
以至於在Ubunut/Debian的package太舊了也沒人去跟新
所以使用Gtags的方法必須要下載原始碼後自行編譯,
所幸編譯上非常簡單

Gtags綜合了ctags和cscope的優點
也就是說Gtags可以幫你很正確的找到function definition, function caller, function callee.
但Gtags也是有缺點的, 最大的缺點應該是界面很難用, 我認為這
應該是使用率較低的原因

不過近來Joe Steffen替Gtags寫了一個新的界面
讓Gtags可以透過cscope的界面與外部溝通稱之為gtags-cscope
http://www.gnu.org/software/global/globaldoc.html#SEC34
只要在Vim裡設置

set csprg=gtags-cscope
cs add GTAGS

Gtags就可以如同Cscope般使用

此外,
Gtags還有一個很重要的優點
那就是gtags可以incrementally update
每當文件修改後就會發生tag無法對上的問題
對ctags來說解決方法就是重新產生一個新的tag
對cscope來說問題就更大了
因為在Vim裡Cscope是藉由呼叫外部程式
而這個程式會將Cscope的tag lock住
所以每當要update tag必須先將Vim關閉
但Gtags就沒有這個問題,
要update Gtags僅僅需要在command line裡執行
$ global -u
就行了

2013年6月11日 星期二

Vim plugin from the ONE



Vim裡提供的Omni-complete, 我長久以來一直覺的是一個雞肋, 不只複合鍵難用, 正確率也不高, 也就是說僅處於堪用的階段. 最近看到許多人在討論clang-complete, 還有YouCompleteMe, 但據我的使用經驗要成功把clang的tag編出來還挺費工夫的.




另一個神級neocomplete(https://github.com/Shougo/neocomplete.vim)的插件

解決了這個困擾

不廢話看圖就知道了



不過在Ubuntu12.04上的Vim太舊了而無法支援neocomplete

還好有好心人打包了新的Vim$ sudo add-apt-repository ppa:fcwu-tw/ppa $ sudo apt-get update $ sudo apt-get install vim


總而言之
真是太神了!!

參考資料:
1. https://github.com/Shougo/neocomplete.vim
2.http://rickey-nctu.blogspot.tw/2013/05/vim-youcompleteme.html

2013年5月24日 星期五

在nexus 4上使用adb

將nexus 4連上usb後, 卻發現adb找不到devices.
心念很快一轉,這一定是usb debug選項沒有開啟
進到settings後卻怎麼也找不到developer options.
原來Google在4.2以後將developer options給隱藏了起來
開啟的密技是進到About Phone後
向下轉到最後一項Build Number連點7下
你就可以成功拿回developer options,
有趣的是當你點三下後, Nexus 4會告訴你你還差4下就可以成為developer. Funny Ha?


參考資料:
http://www.androidcentral.com/how-enable-developer-settings-android-42

2013年4月26日 星期五

找不到libpython2.6.so.1.0

prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gdb: error while loading shared libraries: libpython2.6.so.1.0

解決方法:
$ sudo add-apt-repository ppa:fkrull/deadsnakes
$ sudo apt-get update
$ sudo apt-get install libpython2.6

參考資料:
http://e2e.ti.com/support/arm/sitara_arm/f/791/t/205822.aspx

2013年1月22日 星期二

我所不知道的Vim

這裡紀錄一下新學會的Vim Command
1. Vim diff裡尋找上一個與下一個差異
]c 與 [c

2013年1月9日 星期三

讓一般user使用/dev/ttyUSB0

一開始我認為只要把user加入dialout的group就好了, 結果還是遇到permission denied的問題

還好找到了以下的solution

$ sudoedit /etc/udev/rules.d/50-ttyusb.rules

貼上


KERNEL=="ttyUSB[0-9]*",NAME="tts/USB%n",SYMLINK+="%k",GROUP="uucp",MODE="0666"K+="%k",GROUP="uucp",MODE="0666"

參考資料:
How do I allow a non-default user to use serial device ttyUSB0?