Linux2010. 3. 17. 16:24
grep --color=auto 를 하면 자동으로 색상을 넣어주는데
검색 키워드를 "빨간색"으로 넣어주는 기능이 좀 마음에 든다.
그런데 가끔, 검색 내용뿐만 아니라 전체 내용에서 그 부분만 색상을 바꾸고 싶다면 어떻게 하면 되려나?
(일종의 터미널용 문법강조/신택스 하이라이트/syntax highlight)

grep 명령어에는 Before & After를 지원한다.
       -A NUM, --after-context=NUM
              Print NUM  lines  of  trailing  context  after  matching  lines.
              Places  a  line  containing  --  between  contiguous  groups  of
              matches.

       -B NUM, --before-context=NUM
              Print  NUM  lines  of  leading  context  before  matching lines.
              Places  a  line  containing  --  between  contiguous  groups  of
              matches.

[링크 : http://linux.die.net/man/1/grep]

검색어의 앞뒤로 조금더 출력해주느 기능인데, 검색어들 간에 거리가 적당하게 유지된다면
특정값을 넣어주면, 전체 문서에서 그 부분만 색상이 변해서 나오게 된다.

문서의 전체 길이를 재려면
"wc -l" 로 하면되고
       -l, --lines
              print the newline counts

[링크 : http://linux.die.net/man/1/wc]

파일이 아닐경우 pipe를 통해 넘겨주면 된다.

예를들어 grep의 manpage 에서 it만 강조하고 싶다면
# man grep | grep -A `man grep | wc -l` -B `man grep | wc -l` it
라고 입력하면 된다.

아래는 it의 빈도가 낮아서 a로 바꾸어서 검색해본 결과.
a에만 색상이 나오고 터미널 스크롤바는 길어지고 ㅋㅋ

음.. 깔끔한 방법은 없나?

Posted by 구차니
프로그램 사용/vi2009. 5. 26. 22:51
1.3. Install Vim on Debian GNU/Linux

To install Vim on Debian Linux (GNU Linux), login as root and when connected to internet type -

apt-get install vim vim-rt

It will download the latest version of vim, install it, configure it. The first package listed is vim, the standard editor, compiled with X11 support, vim-rt is the vim runtime, it holds all the syntax and help files.

On Debian 3.0 (woody) and above, use 'apt-get install vim' instead. The vim-rt package is part of the main vim package.

[링크 : http://www.faqs.org/docs/Linux-HOWTO/Vim-HOWTO.html]


우분투에 9.04 기본으로 설치된 VI는 문법강조가 작동하지 않는다.
그래서 위의 방법대로 했더니 vim-rt는 존재하지 않고 vim-runtime 패키지가 존재 한다.

$ sudo apt-get install vim
라고 입력하면 알아서 추천하고 알아서 설치해준다.
Posted by 구차니
프로그램 사용2009. 1. 18. 16:09
듬직이님의 블로그에서 발견한 플러그 인으로, 소스 코드를 간혹 올리는 나로서는 상당히 부러운 기능이었다.
간만에 구차니즘을 털어 내고 조금 노가다를 해보았다.

일단 설치시에는 별 문제는 없지만,
설치 후에 padding이 제대로 먹지 않아서 첫째 줄과 아래 소스들의 줄이 안 맞는 문제와
copy to clipboard가 안 되는 문제가 발견되었다.

소스들의 줄이 안 맞는 문제는 BLUE'nLIVE 님의 블로그에서 수정 방법을 발견했지만,
copy to clipboard가 안되는 것 역시 BLUE'nLIVE님의 블로그에서 발견하였다. ㄱ-

테스트
#include <stdio.h>
#define TEST_DEBUG
int test = 0x123;
char teststr[] = "Hello world";

// this is test source code
/* multi line commentstest area */

LONG WINAPI RegSetValueEx
(
   __in        HKEY hKey,
   __in_opt    LPCTSTR lpValueName,
   __reserved  DWORD Reserved,
   __in        DWORD dwType,
   __in_opt    const BYTE *lpData,
   __in        DWORD cbData );


[다운 : http://code.google.com/p/syntaxhighlighter/]
[설치 : http://gyuha.tistory.com/193]
[수정 : http://bluenlive.net/entry/Code-Highlighter-마이너-버그패치]
[수정: http://bluenlive.net/entry/블로그팁-Code-Highlighter-더-쉽게-사용하기]
Posted by 구차니