Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

Astro Coke

[Python & VI] Vi folding 을 class 나 def 에 따라 접도록 설정하기 본문

Computer Setup

[Python & VI] Vi folding 을 class 나 def 에 따라 접도록 설정하기

astrodoo 2019. 4. 7. 04:53

기본적으로 python을 vi 를 통해 스크립트를 작성할때

indent로 folding 을 한다. 

 

기본 설정 in .vimrc:

 

" folding settings

autocmd FileType python set foldmethod=indent           " use indent for folding (python)

autocmd FileType python set foldnestmax=1                       " maximal level of folding

autocmd FileType python set expandtab                           " insert spaces instead of <TAB>

 

하지만 간혹 class 내에 서브 함수들을 folding 하는 것에는 한계가 있다.

foldnestmax=2 로 설정을 해도 원하는 데로 깔끔하게 folding 이 되지는 않는다.

 

한 방법은,

 

folding 방법을 express 로 설정을 하고

syntax 에 express 를 추가하는 방법이다.

 

복잡해 보이나 이미 express script가 인터넷에 있어 

쉽게 구현할 수 있다.

 

우선 python.vim 을 아래 링크에서 다운받아 (아래 링크)

 

python.vim
0.00MB

혹은

https://www.vim.org/scripts/script.php?script_id=781

 

~/.vim/syntax/

폴더안에 복사를 한다.

 

그리고 .vimrc 를 다음과 같이 수정하면 끝~!

 

" folding settings

autocmd FileType python set foldmethod=expr           " use syntax for folding (python)

autocmd FileType python set foldnestmax=1                       " maximal level of folding

autocmd FileType python set expandtab                           " insert spaces instead of <TAB>