"Vim"의 두 판 사이의 차이

ph
이동: 둘러보기, 검색
잔글
5번째 줄: 5번째 줄:
 
아래와 같이 하면 탭등 구분은 안되지만 일단 공백이 다른 색으로 보임.
 
아래와 같이 하면 탭등 구분은 안되지만 일단 공백이 다른 색으로 보임.
 
  :syntax on
 
  :syntax on
  :set syntax=whitespace
+
  :set syntax=whitespace   [https://stackoverflow.com/a/19012475/766330]
[https://stackoverflow.com/a/19012475/766330]
 
  
 
==autocomplete에 dash포함==
 
==autocomplete에 dash포함==

2017년 10월 30일 (월) 18:19 판

Make Vim show ALL white spaces as a character

:set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣
:set list

[1]
아래와 같이 하면 탭등 구분은 안되지만 일단 공백이 다른 색으로 보임.

:syntax on
:set syntax=whitespace   [2]

autocomplete에 dash포함

:set lisp [3]

다른 방법으로는,

:set iskeyword+=\- [4]

이용

Auto completion in command line mode

:help wildmode  

I am using

:set wildemode=list:longest

Display line numbers

:highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE  

[5]


이미 읽은 파일의 인코딩 변경

:e ++enc=euc-kr

[6]


tab으로 편집

:help tabpage
:help tabe

ref. :Te


temporary ic when searching

insert '\c'(or '\C') at the end. (eg: /example\c will match with 'Example').
ref. :help pattern


Gnu indent

function! GnuIndent()
   setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1,//0
   setlocal shiftwidth=2
   setlocal tabstop=8
endfunction
au FileType c,cpp,php call GnuIndent()


Copy using t command

:81,91t.<enter>

Copy the current lines to your present cursor location. [7]

Change tab(\t) to space

:set expandtab
:retab

[8]

Reverse all lines

:g/^/m0

g: reg match인 모든 곳에서 명령실행

혹은 다음과 같이 한다.

:%!tac

[9]

non-greedy match

.\{-}

[10]

Match except last parenthesis

:%s/\(.\{-}\)\( \?([^)]*)\)\?$/[[\1]]\2/

‘optional한 마지막 괄호’만 빼고 다른 모든것을 매치하고 싶었는데, stackoverflow에 물어보니 ‘닫는괄호를 제외한 나머지’와 match하는게 핵심 아이디어 였음. 즉, 괄호 match에 다음을 쓰는 것.

([^)]*)[11]

magic을 이용한 방법[12]이 더 깔끔해보이긴 함

/\v(^\w+(\s\w+)?)
:%s,,[[\1]],g

Regexp with magic

\v

vimdoc참고. 훨씬 깔끔해진다.