You know that you can use “make” in your vim environment without any configuration but just go with command mode and just call “make”

But I’m very sure that you are wanna use your own build script instead of using bare “make”

Yes there is a tip for you certainly.

The option to assign a make program with your taste in vim is “makeprg”. Le me show you how it works.

Just leave this option in your .vimrc configuration file with your favorite build script like following

set makeprg=../build.sh

With only this configuration, you can use your favorite build script with fully customized in your taste.

And there is one more thing. The “quickfix” a feature of vim which helping you with jump into the warnings or errors which come after the build process. After the build process through your own script assigned with “set makeprg”, you might want to trace the warning you got after the build process and error as well.

The command for quickfix is “copen” and yes correctk it goes off with “cclose”.

I attached my own setting for vim bellow with bunch of shortkeys

더보기

And the build script I’m using for kernel build

더보기

이올린에 북마크하기(0) 이올린에 추천하기(0)
크리에이티브 커먼즈 라이선스
Creative Commons License

Tag : build script, copen, cw, makeprg, vim

Configuring your own vim

Posted 2009/06/09 11:44 by kdsoo

Description TBD

set tags=./tags,/usr/src/linux/tags,/usr/include/tags
set number

set csprg=/usr/bin/cscope
set csto=0
set cst
set mouse=a
set nocsverb
set encoding=utf-8
"set sw=4
"set tabstop=8
"set expandtab
set autoindent
set cindent
set smartindent
set ruler
set wmnu
set lpl
set ic
set scs
set sc
set sm
set sel=exclusive

abbr #b /*********************************************************
abbr #e *********************************************************/

"color advantage
color impact

if $LANG[0] == 'k' && $LANG[1] == 'o'
set fileencoding=korea
endif

if &t_Co > 2 || has("gui_running")
    syntax on
    set hlsearch
endif

if &term=="xterm"
    set t_Co=8
    set t_Sb=^[[4%dm
    set t_Sf=^[[3%dm
endif

if filereadable("./cscope.out")
        cs add cscope.out
else
        cs add /home/share/linux/cscope.out
endif
set csverb

if version >= 500
func! Sts()
        let st = expand("<cword>")
        exe "sts ".st
endfunc
nmap ,st :call Sts()<cr>

func! Tj()
        let st = expand("<cword>")
        exe "tj ".st
endfunc
nmap ,tj :call Tj()<cr>
endif

map ,1 :b!1<CR>
map ,2 :b!2<CR>
map ,3 :b!3<CR>
map ,4 :b!4<CR>
map ,5 :b!5<CR>
map ,6 :b!6<CR>
map ,7 :b!7<CR>
map ,8 :b!8<CR>
map ,9 :b!9<CR>
map ,0 :b!0<CR>
map ,w :b!bw<CR>

map <F1> v]}zf

nnoremap <silent> <F2> :copen<CR>
nnoremap <silent> <F3> :cclose<CR>
nnoremap <silent> <F4> :make uImage<CR> :cw 7<CR>
nnoremap <silent> <F5> :cs find f 
nnoremap <silent> <F6> :BufExplorer<CR>
nnoremap <silent> <F7> :Tlist<CR>
nnoremap <silent> <F8> :make cscope ARCH=arm<CR> :cs kill 0<CR> :cs add cscope.out<CR>

func! Man( )
    let sm = expand("<cword>")
    exe "!man -S 2:3:4:5:6:7:8:9:tcl:n:l:p:o ".sm
endfunc
nmap <F9> :call Man( )<cr><cr>

nmap <C-[>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-[>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-[>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-[>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-[>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-[>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-[>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-[>d :cs find d <C-R>=expand("<cword>")<CR><CR>

" Show trailing whitespace and spaces before tabs
hi link localWhitespaceError Error
au Syntax * syn match localWhitespaceError /\(\zs\%#\|\s\)\+$/ display
au Syntax * syn match localWhitespaceError / \+\ze\t/ display
크리에이티브 커먼즈 라이선스
Creative Commons License

Tag : vi, vi shortcut keys, vim, vim shortcut keys, vimrc

Vim with git plugin (git-vim)

Posted 2009/02/24 19:42 by kdsoo

vi(vim)로 git repository 에서 작업하다 보면 터미널을 하나 더 띄우거나 쉘을 vim 에서 fork 해서 띄워서 git 을 확인해야 할 경우가 많다.

 

간편하게 vim plugin 으로 이 작업들을 해결 가능하다.

 

Git plugin

Plugin : http://github.com/motemen/git-vim/tree/master

 

위의 repository 에서 받을수 있다.

주의할 점은 vim 7.1 이상만 지원하는 듯 하다.

 

Git plugin 설치

plugin 디렉토리와 syntax 디렉토리가 있고 각각의 디렉토리 안에 .vim 플러그인들이 있다.

본인의 계정에

 

    1. .vim/ 디렉토리가 없으면 만들고
    2. 그 안에 plugin 과 syntax 디렉토리를 없으면 만들고
    3. plugin, syntax 디렉토리에 앞서 받은 git-vim plugin 들을 카피해 넣는다.

 

kdsoo@chromatix:~$ pwd
/home/kdsoo
kdsoo@chromatix:~$ ls -al .vim
total 64
drwxr-xr-x  6 kdsoo kdsoo       4096 2009-02-24 19:05 .
drwxr-xr-x 73 kdsoo kdsoo       4096 2009-02-24 19:38 ..
drwxr-xr-x  2 kdsoo kdsoo       4096 2008-10-17 09:32 colors
drwxr-xr-x  2 kdsoo kdsoo       4096 2009-02-24 19:06 doc
drwxr-xr-x  2 kdsoo kdsoo       4096 2009-02-24 19:30 plugin
drwxr-xr-x  2 kdsoo kdsoo       4096 2009-02-24 19:18 syntax

 

git-vim 의 사용

기본 키맵은 다음과 같이 매핑 되어있다.

 

== Keymaps
[<Leader>gd] :GitDiff
[<Leader>gD] :GitDiff --cached
[<Leader>gs] :GitStatus
[<Leader>gl] :GitLog
[<Leader>ga] :GitAdd
[<Leader>gA] :GitAdd <cfile>
[<Leader>gc] :GitCommit

 

=== In git-status buffer
[<Enter>]    :GitAdd <cfile>

 

쉽게 설명하면 vim 의 command mode, 즉 esc 를 한번 누른 상태에서

 

\gs

 

라고 입력하면 GitStatus 명령을 친것과 같이 동작한다.

 

즐거운 vi & git 생활 되시길.

이올린에 북마크하기(0) 이올린에 추천하기(0)
크리에이티브 커먼즈 라이선스
Creative Commons License

Tag : git, git-vim, Linux, vim

vi 와 Linux programmer&rsquo;s manual 연동

Posted 2009/02/12 13:58 by kdsoo

vi 에서 코드 분석하거나 작성할때 C 함수들을 쉘에서 man page 를 통해 볼수 있지만

 

vi 에서 곧바로 확인하는 방법이 있습니다.

 

우선 개발자용 맨페이지를 받아야하는데요

 

1. ubuntu 기준으로

    sudo apt-get install manpages-dev

하시면 Linux programmer's manual 을 받을수 있습니다. (리눅스는 섹션 2네요...솔라리스나 HPUX 같은건 7 이었던 것 같은데..)

 

2. vi 에서 표준 C 함수에 커서를 놓고 shift + k 를 누르시면 해당 함수의 매뉴얼이 나옵니다.

 

즐개발~

이올린에 북마크하기(0) 이올린에 추천하기(0)
크리에이티브 커먼즈 라이선스
Creative Commons License

'[3] My specialty' 카테고리의 다른 글

git pull & patch 간략 정리  (0) 2009/02/18
Hello San Francisco.  (0) 2009/02/13
vi 와 Linux programmer&rsquo;s manual 연동  (0) 2009/02/12
cscope with linux kernel source code  (0) 2009/02/10
Firefox url bar problem on Ubuntu 8.04  (0) 2009/02/02
V4L2 개발 관련 정리.  (0) 2009/01/21

Tag : Linux programmer's manual, man page, MSDN, vi, vim

cscope with linux kernel source code

Posted 2009/02/10 09:17 by kdsoo

cscope 를 사용하시면 커널소스안에서 파일 위치나 함수 위치 같은걸 기억하지 않아도 금방 찾을수 있습니다.

심볼 싱크하는 시간도 IDE 들에 비해 훨씬 빨라서 좋습니다.(아무리 늦어도 30초 이내에 전체 프로젝트가 싱크됨)

 

0. cscope 설치.

ubuntu 기준으로

sudo apt-get install cscope

 

1. vim에 cscope 인식

우선 자신의 계정에 .vimrc 를 열어서 편집합니다.

set csprg=/usr/bin/cscope

......

if filereadable("./cscope.out")

        cs add cscope.out

else

        cs add /home/share/linux/cscope.out

endif

set csverb

이걸 추가 해주시구요.

 

2. cscope 싱크

커널 소스의 최상위 디렉토리에서

kdsoo@chromatix:/home/share/GIT/OMAP3430/linux-2.6.29-rc3-omap$ make cscope

합니다.

그럼 cscope index 를 만들기 시작합니다.

 

3. 기본적인 사용법

kdsoo@chromatix:/home/share/GIT/OMAP3430/linux-2.6.29-rc3-omap$ vi .

위와 같이 커널소스 최상위 디렉토리에서 "vi ." 이라고 치시면 vim 이 cscope 가 생성한 db와 연동하여 open 됩니다.

 

4. cscope 기본 명령어

vi 의 command mode (: 를 누르면 들어감) 에서

    - 파일 찾기: cs find f 파일명

    - 심볼 찾기 : cs find s 심볼

    - 함수등의 원형 찾기 : cs find g 심볼

    - 해당함수를 호출하는 함수 찾기 : cs find c 심볼

    - 해당함수가 호출하는 함수 찾기 : cs find d 심볼

더 있는데 저는 대충 이거만 써서...

사용법은 vim의 command mode 에서

:cs

라고 치시면 나오니 참고하세요.

 

5. 단축키 만들기

단축키 만들어 두면 편합니다.

.vimrc에 다음을 구미에 맞게 추가하세요. (F 키는 키보드의 펑션키를 말함..취향에 맞게 변경해 쓰세요)

    - cscope db 빌드 단축키 (F8)

    nnoremap <silent> <F8> :make cscope ARCH=arm<CR> :cs kill 0<CR> :cs add cscope.out<CR>

    - 파일찾기 단축키

    nnoremap <silent> <F5> :cs find f

 

6. vim visual mode 에서 cscope 연동

vim 의 visual mode (마우스로 해당 심볼을 선택가능한 모드)에서

해당 심볼을 마우스로 선택하고(그냥 원클릭)

ctrl + [ 를 누른후 s g c t e 등의 cscope 커맨드 옵션을 입력하면

cs find "옵션" 심볼

과 같은 효과를 낼수 있습니다.

다음을 .vimrc에 추가하세요.

nmap <C-[>s :cs find s <C-R>=expand("<cword>")<CR><CR>

nmap <C-[>g :cs find g <C-R>=expand("<cword>")<CR><CR>

nmap <C-[>c :cs find c <C-R>=expand("<cword>")<CR><CR>

nmap <C-[>t :cs find t <C-R>=expand("<cword>")<CR><CR>

nmap <C-[>e :cs find e <C-R>=expand("<cword>")<CR><CR>

nmap <C-[>f :cs find f <C-R>=expand("<cfile>")<CR><CR>

nmap <C-[>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>

nmap <C-[>d :cs find d <C-R>=expand("<cword>")<CR><CR>

위 옵션들을 추가하면 vim 에서 원하는 심볼을 선택하고 해당 심볼을 call 하는 심볼을 찾는 작업등을 할수 있습니다.

그럼 즐거운 vi 생활 되세요.

추가로... 지금 열고있는 소스파일의 심볼 목록을 쉽게 보고 싶으신 경우를 위해 다음 단축키도 편하게 사용하실수 있습니다.

nnoremap <silent> <F7> :Tlist<CR>

이올린에 북마크하기(0) 이올린에 추천하기(0)
크리에이티브 커먼즈 라이선스
Creative Commons License

'[3] My specialty' 카테고리의 다른 글

Hello San Francisco.  (0) 2009/02/13
vi 와 Linux programmer&rsquo;s manual 연동  (0) 2009/02/12
cscope with linux kernel source code  (0) 2009/02/10
Firefox url bar problem on Ubuntu 8.04  (0) 2009/02/02
V4L2 개발 관련 정리.  (0) 2009/01/21
Diff tools  (0) 2009/01/16

Tag : cscope, Linux Kernel, vi, vim