관심있는 것들 정리

vim 사용 시 diffmode 와 일반 모드 구분하기 본문

utility 사용법/vim

vim 사용 시 diffmode 와 일반 모드 구분하기

내공강화 2015. 2. 3. 23:28

vim 사용 중

파일을 diff하기 위해 일반적으로 command line에서 

> vim -d source_code1.c  source_code2.c

와 같이 입력하여 작업을 수행한다.

이 때 다음과 같은 이유로 일반 모드와 diffmode를 구분하여 설정이 되도록 하기 원할 때가 있다.

  - 일반 editing시와 다른 colorscheme을 적용하고 싶다

  - shiftwidth나 tabstop 간격을 다르게 조정하고 싶다

  - 그 외

이 때 다음과 같은 구문을 .vimrc 파일에 입력하면 가능하다.

if &diff

“ diffmode

colorscheme blue

else

“ normal editing mode

colorscheme koehler

endif

 

예: mac용 terminal에서 편집용으로 연 간단한 python 파일은 다음과 같이 보인다.

Test vim screen1

 

colorscheme을 koehler로 한 상태에서 diff를 할 경우, 새로 추가된 line이 잘 보이지 않는 단점이 있다.
Test vim screen2 

이 때 .vimrc를 수정하여 diff인 경우 evening scheme을 쓰도록 수정할 경우 다음과 같이 diff시에는 좀 더 가독성이 높은 화면을 볼 수 있다.
Test vim screen3 

반응형