탭 키 == 4 공백과 vim의 곱슬 교정기 후 자동 인도
-
04-07-2019 - |
해결책
아래 몇 가지 답변에서 지적 된 바와 같이, 선호하는 방법은 이제 Smartindent를 사용하지 않고 다음을 사용하는 것입니다 ( .VIMRC):
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
당신의 .VIMRC : 파일:
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
도움말 파일은 익숙해지는 데 약간의 시간이 걸리지 만 읽을수록 더 나은 vim을 얻습니다.
:help smartindent
더 나은 것은 휴대 성을 위해 소스에 이러한 설정을 포함시킬 수 있습니다.
:help auto-setting
현재 설정을 확인하려면 :
:set all
처럼 그레이 워드 주석에서 SmartIndent는 CINDENT로 대체되었지만 여전히 C와 같은 구문이있는 언어에 대해서는 여전히 "더 영리하게 작동"합니다.
:help C-indenting
다른 팁
관련, 탭과 공백을 모두 사용하는 파일을 열면
set expandtab ts=4 sw=4 ai
모든 탭을 전체 파일의 공백으로 바꿀 수 있습니다.
:%retab
Filetype 특정 압입을 얻는 가장 좋은 방법은 사용하는 것입니다. filetype plugin indent on
VIMRC에서. 그런 다음 같은 것을 지정할 수 있습니다 set sw=4 sts=4 et
예를 들어 .vim/ftplugin/c.vim에서, 모든 파일을 편집 할 필요없이 기타 비 C 유형 구문도 올바르게 들여 쓰기됩니다. (심지어 lisps).
대부분의 파일에 4 개의 공간 탭, makefiles의 실제 8 층 탭 Char 및 C/C ++를 포함한 다양한 파일에서 자동 들여 쓰기를 보려면이를 입력하십시오. ~/.vimrc
파일:
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Use filetype detection and file-based automatic indenting.
filetype plugin indent on
" Use actual tab chars in Makefiles.
autocmd FileType make set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab
endif
" For everything else, use a tab width of 4 space chars.
set tabstop=4 " The width of a TAB is set to 4.
" Still it is a \t. It is just that
" Vim will interpret it to be having
" a width of 4.
set shiftwidth=4 " Indents will have a width of 4.
set softtabstop=4 " Sets the number of columns for a TAB.
set expandtab " Expand TABs to spaces.
Ubuntu와 같은 많은 Linux 시스템에서 .vimrc
기본적으로 파일이 존재하지 않으므로 먼저 작성하는 것이 좋습니다.
사용하지 마십시오 .viminfo
홈 디렉토리에 존재하는 파일. 다른 목적으로 사용됩니다.
1 단계 : 홈 디렉토리로 이동하십시오
cd ~
2 단계 : 파일을 만듭니다
vim .vimrc
3 단계 : 위에서 언급 한 구성을 추가하십시오
filetype plugin indent on
set tabstop=4
set shiftwidth=4
set expandtab
3 단계 : 눌러 파일을 저장합니다 옮기다 + ZZ.
권장되는 방법은 Filetype 기반 압입을 사용하고 충분하지 않은 경우 Smartindent 및 Cindent 만 사용하는 것입니다.
.vimrc에 다음을 추가하십시오
set expandtab
set shiftwidth=2
set softtabstop=2
filetype plugin indent on
다른 대답이되기를 바랍니다.
~/.vimrc를 편집하십시오
$ vim ~/.vimrc
다음 줄 추가 :
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
로부터 Vim Wiki:
:set tabstop=4
:set shiftwidth=4
:set expandtab
자동 인도는 현재 구문 모드를 기반으로합니다. 나는 당신이 foo.java를 편집하고 있다면 {
그리고 타격 입력하다 다음 줄을 들여 쓰기.
탭의 경우 두 가지 설정이 있습니다. Vim 내에서 A를 입력 한 다음 "Tabstop = 4"를 설정하여 탭을 4 개의 공간으로 표시하도록 설정합니다. 콜론을 다시 누르고 탭의 공백을 삽입하는 "ExpandTab 세트"를 입력하십시오.
이 설정을 홈 디렉토리에 .vimrc (또는 Windows의 _vimrc)에 넣을 수 있으므로 한 번만 입력하면됩니다.