달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'Tool/editor & source viewer'에 해당되는 글 4건

  1. 2011.05.23 cscope
  2. 2011.03.01 Source Explorer - Vim 에서 Source Insight 따라잡기
  3. 2011.03.01 vim 이용하기 (내가 필요한 것만...)
  4. 2007.12.31 vim 이용

cscope

Tool/editor & source viewer 2011. 5. 23. 23:22
cscope - interactively examine a C program

i.e) cscope -R
i.e) cscope -b -q -k -R
i.e) cscope -d

-sdir  Look in dir for additional source files. This option is ignored if source files are given on the command line.

-R     Recurse subdirectories during search for source files.

-b     Build the cross-reference only.

-q     Enable fast symbol lookup via an inverted index. This option causes cscope to  create  2  more  files (default  names  ``cscope.in.out''  and  ``cscope.po.out'')  in addition to the normal database. This allows a faster symbol search algorithm that provides noticeably faster lookup performance for  large projects.

-k     ``Kernel Mode'', turns off the use of the default include dir (usually /usr/include)  when  building the database, since kernel source trees generally do not use it.

-d     Do not update the cross-reference.

<vim plugin>
$ cd ~/.vim/plugin
$ wget http://cscope.sourceforge.net/cscope_maps.vim

    " The following maps all invoke one of the following cscope search types:
"
" 's' symbol: find all references to the token under cursor
" 'g' global: find global definition(s) of the token under cursor
" 'c' calls: find all calls to the function name under cursor
" 't' text: find all instances of the text under cursor
" 'e' egrep: egrep search for the word under cursor
" 'f' file: open the filename under cursor
" 'i' includes: find files that include the filename under cursor
" 'd' called: find functions that function under cursor calls
아래와 같이 Ctrl + \ 에 위 단축 알파벳을 입력하면 된다.
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>

그밖에 Ctrl + space 로 찾은 결과를 새 Window에서 볼 수 있으며,
nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>

Ctrl + space + space 로 Vertical Split도 가능하다.
nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
Posted by neodelicious
|

srcexpl.vim

vim_plugin.tgz


편한 IDE가 많겠지만 개인적으로 Linux의 Source를 Windows 에서 Source Insight로 분석하고 편집한다. Linux에서 Eclipse가 좋다고는 하지만 느린 것도 같고 UI가 불편하다.

Linux에서 source를 좀 보려고 vi를 열면서 혹시나 해서 'Linux Source Insight'로 구글에게 물어봤더니 아래 Link를 알려주었다.

http://linux.softpedia.com/get/Text-Editing-Processing/Others/Text-Editor/Vim-Plugins/Source-Explorer-39586.shtml

Source Explorer 라는 Vim plugin 인데, source code에서 함수나 변수에 커서를 가져가면 선언부를 아래에 보여준다.

아래와 같이 Vim 윗 부분에 mProfile 변수에 대해서 아랫부분에 선언부분을 보여준다. 사실 이 plugin은 ctags 의 TAG에 의존하기 때문에 ctags 기능인 ctrl + } 와 ctll + t 입력도 가능하고, ctrl + w, w 를 통해서 아래 preview 부분도 이동해서 scroll 해 볼 수 있다.


이제 위 Source Explorer 를 이용하는 방법을 알아보자.

우선 현재 system에 Vim가 설치되어 있어야 한다. 그런데 기본 Ubuntu의 경우 vim-basic이 아니라 vim-tiny가 설치되어 있다.

vi 는 아래와 같이 /etc/alternatives/vi 로 symbolic link 되어 있는데,

$ ls -l /usr/bin/vi
 /usr/bin/vi -> /etc/alternatives/vi

이를 다시 확인해 보면 아래처럼 vim.tiny 라는 것을 알 수 있다.

$ ls -l /etc/alternatives/vi
 /etc/alternatives/vi -> /usr/bin/vim.tiny

만약 이미 아래와 같이 vim.basic 이라면 상관 없지만,

$ ls -l /etc/alternatives/vi
 /etc/alternatives/vi -> /usr/bin/vim.basic

아니라면 아래처럼 vim 을 설치한다.

$ sudo apt-get install vim

참고적으로 https://lists.ubuntu.com/archives/sounder/2006-September/008662.html 에 아래와 같은 글도 있더라...

AFAIK 'vim-tiny' is a very basic build of 'vim' with most optional
features disabled, so that it is functionally pretty close to the
original 'vi'.
You could say it's "vim de-improved"...  ;-)

이제 Source Explorer 를 설치해야 한다. 직접 Link 에서 받거나 첨부파일에서 srcexpl.vim 을 받아 plugin 에 복사한다. 만약 plugin 디렉토리가 없으면 만들면 된다.

$ cp srcexpl.vim /home/jaeawon/.vim/plugin

그리고 Source Explorer 는 ctags의 TAG가 필요하기 때문에,
ctags 가 없다면 우선 설치하고,

$ sudo apt-get install exuberant-ctags
해당 source path로 이동하여 TAG 정보를 생성한다.
$ ctags -R .

끝으로 source path 안에 source 파일을 열고 :SrcExplToggle 를 입력하면 Source Explorer를 즐길(?) 수 있다.

참고적으로 srcexpl.vim 파일 맨 위에 설명도 있는데, 환경 설정을 일부 할 수 있는데, 나는 아래 것 하나만 .vimrc 에 넣어서 F8로 하도록 했다.

nmap <F8> :SrcExplToggle<CR>

그리고 Link 페이지에 있는 Taglist 와 MiniBufExpl 도 쓸만한 plugin 이다.


'Tool > editor & source viewer' 카테고리의 다른 글

cscope  (0) 2011.05.23
vim 이용하기 (내가 필요한 것만...)  (0) 2011.03.01
vim 이용  (0) 2007.12.31
Posted by neodelicious
|
아래 vim 문서를 보다가 일부 정리함....
http://www.truth.sk/vim/vimbook-OPL.pdf

<line 이동하기>
$ - 현재 line 끝으로 이동
2$ - 1 line 아래 끝으로 이동
3$ - 2 line 아래 끝으로 이동

<search - 1>
f - 현재 line에서 우측 방향으로 처음 알파벳이나 숫자 등의 위치로 이동 (예, fa 는 우측 첫 a 위치)
F - 현재 line에서 좌측 방향으로 처음 처음 알파벳이나 숫자 등의 위치로 이동 (예, Fa 는 좌측 첫 a 위치)

<search - 2>
/ 는 forward search, ? 는 backward search 이다.
n 는 현재 방향으로 반복 search, N 는 방향을 바꿔서 반복 search
'/' 입력하고 PgUp 이나 PgDn 으로 이전에 찾았던 키워드를 이용할 수 있다.

<search - 3>
:set hlsearch    - search 결과를 highlight 하도록 설정한다.
:set nohlsearch - search 결과를 highlight 하지 않도록 설정한다.
:nohlsearch      - 현재 highlight 한 search 결과에 한해서만 highlight 해제한다.

<windows>
split hello.c 으로 hello.c 을 새 window 에서 보여줄 수 있다.
vsplit 으로 vertical 하게 새 window를 보여줄 수도 있다.
split, vsplit은 각각 sp, vs으로 약자로 이용할 수 있다.
ctrl-w,w 로써 두 split window 사이에 커서를 옮겨다닐 수 있다

<programmer - 1>
>> 혹은 << 로 우측 혹은 좌측으로 shift 할 수 있다.
이때 간격 기본은 8이며 이를 :set shiftwidth=4 처럼 변경할 수 있다.

<programmer - 2>
% 는 {} () [] 와 같이 짝이 되는 행을 찾아 준다.
예를 들어 { 가 있는 행에서 % 하면 짝이 되는 } 가 있는 행으로 이동한다.
>% 혹은 >i{ 는 {} 포함 혹은 미포함하여 indentation을 맞추는데 이용한다.

'Tool > editor & source viewer' 카테고리의 다른 글

cscope  (0) 2011.05.23
Source Explorer - Vim 에서 Source Insight 따라잡기  (0) 2011.03.01
vim 이용  (0) 2007.12.31
Posted by neodelicious
|
vim에서 tab 길이 조정 (i.e. : 기본 8에서 4로 조정할 때)

1) 명령 모드
  : set tabstop=4

2) UNIX 상에서
  홈디렉토리에 .exrc 또는 .vimrc 에 set tabstop=4 를 한줄 넣어 줍니다.

'Tool > editor & source viewer' 카테고리의 다른 글

cscope  (0) 2011.05.23
Source Explorer - Vim 에서 Source Insight 따라잡기  (0) 2011.03.01
vim 이용하기 (내가 필요한 것만...)  (0) 2011.03.01
Posted by neodelicious
|