Skip to main content
vim tips


  • how to execute a shell command
    r !command
  • 문자코드 지정 읽기
    vim "+e ++enc=cp932" filename
  • buffer사용




    • open a file as buffer
      :badd f1.txt
    • show list of all the existing buffers
      :buffers
      :ls
      :files
    • go to next buffer
      :bNext
    • back to previous buffer
      :bPrevious
    • delete buffer
      :bdelete f1.txt
      :bdelete 4
  • Folding




    • creating fold or delete




      • zr : create folding
      • zd : delete of folding symbol nearby curosr, e.g., {{{ }}}
      • zE : delete of folding symbol all in a current file
    • open & close folding




      • zo : Open one fold under the cursor
      • zO : Open all folds under the curosr recursively
      • zc : Close one fold under the cursor
      • zC : close all folds under the cursor recursively
      • zR : open all folds
    • Moving over folds
    • [z : move to the start of the cureent open fold
    • ]z : move to the end of the current open fold
    • zj : move downwards to the start of the next fold
    • zk : move upwards to the end of the previous fold
  • Bookmark






    • m{a-zA-Z} : set mark {a-zA-Z} at cursor position
    • ` or `{a-zA-Z} : Jump to the mark
    • :marks : show list all the current marks
  • Move





    • move cursor




      • H : move to top of window
      • M : move to middle of window
      • L : move to bottom of window
    • scrolling relative to cursor




      • z : Redraw, line at top of window
      • zt : similar to z
      • z. : Redraw, line at center of window
      • z- : Refraw, line at bottom of window
    • move




      • [n]H : move, [n] line from top of window
      • [n]L : move, [n] line from bottom of window
      • [n]G : move, [n] line of current file
  • Abbreviate




    :abbreviate ad advertisement
    Howto use: ad
    :ab abb abbreviate // :ab kr Korea
    :ab // print out list of abb
    :unab abb // unable abb
  • 문서중의 전 탭을 스페이스로 변환
  • :set expandtab
  • :%retab


Cscope
cd /usr/ports/devel/cscope/
make & make install





configure

At first we shoudl check the vim configure as following:
vim --version | grep cscope
If it is existed, we can install vim without others.
But if not so, we should install cscope and reconfigure vim makefile.






making cscope

find | grep "\.c$\|\.h$" > cscope.files

or 

# for current directory.

ls | grep "\.c$|\.h$" > cscope.files


cscope -b 
ctag -L cscope.files
;ctag is exuberant-ctags
ctag -n --fields=+ai -L cscop.files

ctags --c-kinds=+p -R /usr/include  or makeing ctags file in /usr/include


# for php
ctags --php-kinds=+cidfv -R . ../php/PEAR
# --{lag}-kindsは、ctags --list-kindsで詳細がわかる




  1. Ctrl-\ c : find the callers of a routine.
  2. Ctrl-\ s : find the uses of a symbol
  3. Ctrl-[ Ctrl-[ s : vertical split find the uses of a symbol
  4. To update a cscope database without closing vim :!cscope -b, then :cs reset


Clewn

vim + gdb
What I also needed was the libncurses5 and libncurses5-dev packages.
4.1 Default mappings:

List of default key mappings:
CTRL-Z  send an interrupt to GDB and the program it is running
       B       info breakpoints
       L       info locals
       A       info args
       S       step
       I       stepi
       CTRL-N  next: next source line, skipping all function calls
       X       nexti
       F       finish
       R       run
       Q       quit
       C       continue
       W       where
       CTRL-U  up: go up one frame
       CTRL-D  down: go down one frame
cursor position: 
CTRL-B  set a breakpoint on the line where the cursor is located
       CTRL-E  clear all breakpoints on the line where the cursor is located
mouse pointer position: 
CTRL-P  print the value of the variable defined by the mouse pointer
               position
       CTRL-X  print the value that is referenced by the address whose
               value is that of the variable defined by the mouse pointer
               position
       CTRL-K  set a breakpoint at assembly address shown by mouse position
       CTRL-H  clear a breakpoint at assembly address shown by mouse position
       CTRL-J  add the selected variable at mouse position to the watched
               variables window
Note: You can tune Vim behavior when using netBeans keys with the mouse
pointer position, by setting Vim balloondelay to a smaller value than its
default. The following setting has been reported to give better results:
:set balloondelay=100 ~
Note: After browsing your code, you can always return rapidly to the line of
code where GDB is currently stopped, by using CTRL-U and CTRL-D.




  • 윈도우 이동
    • ctl + Wt 제일 위 윈도우에 이동
    • ctl + Wb 제일 밑 윈도우에 이동
    • ctl + Wp 현 윈도우에 이동하기 전의 윈도우에 이동
    • ctl + Wr 전 윈도우를 아래방향으로 회전
    • ctl + WR 전 윈도우를 윗방향으로 회전
    • ctl + Wx 현 윈도우를 다음 윈도우로 교체


    • :split 파일명 창을 분활해서 파일을 염
    • :sview 파일명 창을 분활해서 파일을 염 - readonly

    • [수]ctl - W+ 윈도우를 수만큰 크게
    • [수]ctl - W- 윈도우를 수만큼 작게
    • Ctl - W= 전 윈도우를 같은 크기로

Comments

Popular posts from this blog

Sqlite database is locked

sqlite는 embedded system에서 널리 사용되는 무료 dbms?(dbms라고 말하긴 좀 그렇지만, dbms라 불러주자 ㅎ) 이다. 특히 memory db 기능이 아주 유용하다. 그 밖의 dbms에서도 이 기능이 있으나, 이 기능이 지원되는 버전은 대부분 고가이다. 따라서, 무료인 sqlite를 많이들 애용하는 것 같다. 멀티쓰레드를 sqlite DB를 구현하고 롱런테스트를 하다보면, pthread_mutex_lock으로 쓰레드 간의 교착상태를 막아줘도, sqlite lock 에러가 간헐적으로 발생할 것이다. 이에 대해 본인은 다음과 같은 에러 처리 구문을 준비하여 사용하고 있다. sqlite Error가 발생하면, sqlite3_exception함수를 호출한다. 이 함수에서 sqlite error code를 구분하여, 만약, busy 또는 locked이면 최대 2초간 sleep 상태로 만드는 sqlite3_busy_timeout, busy handler를 호출한다. 그 다음, goto 구문으로 재차 sqlite3_exec를 실행한다. 단, sqlite3_exec는 transaction의 begin과 commit 또는 rollback 구문 사이에서 실행한다. 대부분 lock 에러가 발생하더라도 1~2번 실패 후에, 처리된다는 것이 본인의 테스트 결과이다. 단, journal를 WAL로 변경하였음. 기존 journal은 멀티쓰레드 지향적이지 않다는 점을 잊지마시길.... Error Code SQLITE_LOCKED (6): Database Is Locked This error code occurs when you try to do two incompatible things with a database at the same time from the same database connection. For example, if you are in the middle of a SELECT statement and y...

맥OS 사전에 사전 파일 추가하기

1. http://code.google.com/p/mac-dictionary-kit/에서 sdconv를 다운로드 받는다. 2. e4u 등과 같은 사전 파일(stardict 형식)을 다운받는다. 3. 사전 파일의 압축을 풀면, e4u.ifo, e4u.dict.dz, e4u.idx와 같은 파일이 보인다. 4. sdconv 디렉터리 내의 convert 실행 파일로 convert e4u.ifo를 실행한다. 5. 위 과정이 완료되면 아래와 같이 사전에 e4u가 추가된 점을 확인할 수 있다. 6. 순서를 조절하여 사용하면 된다.

gnome screen

screen nano editor에서 빠져나오기 C+x가 screen prefix 일 경우, nano 에디터에서 빠쪄나오기 어렵다. 이때는 C+t, C+z하면 background 처리한 후, kill 명령어로 nano 실행 프로세스를 죽여야 한다.     그리고 crontab -e를 실행할 때, export VISUAL=vim; crontab -e로 실행해라.     screen session title를 변경 원할 경우 C+x, shift+a 하면 각 창 제목을 변경할 수 있다.     user's manual http://www.delorie.com/gnu/docs/screen/screen_toc.html - Run a new screen session # screen - Reattach to a previously detatched session # screen -R - Create a new window. # '''prefix''' c - Kill the current window - after confirmation # '''prefix''' k - 현재 창의 창 번호를 변경하는 방법 예 창번호 3에서 1로 변경할 경우, 먼저 창 3으로 이동한 상태에서 # '''prefix''' :number 1 [enter]하면 창번호3이 1로 변경됨.  - Switch to the other window # '''prefix''' space - Detach & Attach screen を起動した状態で、 # Ctrl-z d or Ctrl-z ^D とすると、screenを起動する前のシェルに戻ります。screenはバックグランドで動いています。これを「Detachedデタッチ」と言います。 Attachedとは「再開」 デタッチしたセッションを確認...