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

Linux Resources Monitoring

dstat Requirements:python Dstat is a versatile replacement for iostat, vmstat and ifstat http://linux.softpedia.com/get/System/Diagnostics/Dstat-1401.shtml  - download the source file  - tar -xvjf dstate-0.7.2.tar.bz2  - cd dstate-0.7.2  - sudo make install 사용법 dstat -cdngys --top-io-adv --top-bio-adv 창넓이가 크면 dstat -cdngys --top-io --top-bio dstat 기본옵션은 -cdngy 2. pktstat requirements: libpcap-devel, ncurses-devel pktstat man page 사용법:sudo pktstat -i eth0 -T -l 실행결과 interface: eth0    total: 43.9Mb (3s) cur: 12.3M (78%) min: 12.3M max: 15.8M avg: 14.5M bps    bps    %      b desc   1.4k   0%   4.3k arp  591.8   0%   1.2k ip proto 88 55.101.66.3 <-> igrp-routers  91.3k   0%  91.3k tcp a100236:4478 <-> console:ssh  42.6k   0% 216.4k tcp a100390:mailprox <-> console:ssh   1.1k   0%   ...

nginx로 다중 포트 설정 및 다중 react app 설정

nginx에 다중 포트 설정하기 react로 여러 webapp를 개발하고, 동일한 서버에 실행시킬 필요가 있다. 이때 간단히 nginx에서 다중포트로 여러 webapp를 동일한 서버에서 실행시킬 수 있다. /etc/nginx/sites-available/에 default 파일이 있다. 보통 port 80로 설정되어 있다. 이 파일을 복사해서 sub로 명명한다.   아래와 같이 포트 8080으로 정하고, react app를 build한 디렉터리를 root <dir>로 지정하고, $> sudo service nginx restart 하면 된다. $>sudo systemctl status nginx.service 로 nginx 상태 확인이 가능하면, $> netstat -ano | grep 8080 으로 8080 포트가 살아있는 또는 외부PC에서  $>telnet ip 8080으로 telnet 접속이 되는지 확인하면 된다. 종종 Nginx 500 Interval Server Error가 발생하는데, 이는 1) root <dir>에서 <dir> 주소가 정확하지 않거나, 2) 파일 권한이 없거나이다. chmod 755 <dir>하면 대부분 해결될 것이다. 그럼 오늘도 유익한 하루 되시길..   

SQLITE Result Codes

#define SQLITE_OK 0 /* Successful result */ /* beginning-of-error-codes */ #define SQLITE_ERROR 1 /* SQL error or missing database */ #define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ #define SQLITE_PERM 3 /* Access permission denied */ #define SQLITE_ABORT 4 /* Callback routine requested an abort */ #define SQLITE_BUSY 5 /* The database file is locked */ #define SQLITE_LOCKED 6 /* A table in the database is locked */ #define SQLITE_NOMEM 7 /* A malloc() failed */ #define SQLITE_READONLY 8 /* Attempt to write a readonly database */ #define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ #define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ #define SQLITE_CORRUPT 11 /* The database disk image is malformed */ #define SQLITE_NOTFOUND 12 /* NOT USED. Table or record not found */ #define SQLITE_FULL 13 /* Insertion failed because data...