Vim이 내 코드를 래핑하는 것을 막을 수없는 이유는 무엇입니까?


115

vim이 Python 코드를 래핑하는 것을 막을 수 없습니다. 내가 :set nowrap챔피언처럼 들어가면 그래도 랩핑.

J분할 된 코드 라인을 통합하기 위해 치면 실제 캐리지 리턴이 삽입 된 것처럼 보입니다. 나는 그것을 막는 이유와 방법을 이해할 수 없습니다.


15
:set nowrap줄 바꿈을 삽입하지 않고 줄 표시를 줄 바꿈하는 것만 방지합니다.
rampion

답변:


115
'textwidth' 'tw'        number  (default 0)
                        local to buffer
                        {not in Vi}
        Maximum width of text that is being inserted.  A longer line will be
        broken after white space to get this width.  A zero value disables
        this.  'textwidth' is set to 0 when the 'paste' option is set.  When
        'textwidth' is zero, 'wrapmargin' may be used.  See also
        'formatoptions' and |ins-textwidth|.
        When 'formatexpr' is set it will be used to break the line.
        NOTE: This option is set to 0 when 'compatible' is set.


'wrapmargin' 'wm'       number  (default 0) 
                        local to buffer
        Number of characters from the right window border where wrapping
        starts.  When typing text beyond this limit, an <EOL> will be inserted
        and inserting continues on the next line.
        Options that add a margin, such as 'number' and 'foldcolumn', cause
        the text width to be further reduced.  This is Vi compatible.
        When 'textwidth' is non-zero, this option is not used. 
        See also 'formatoptions' and |ins-textwidth|.  {Vi: works differently
        and less usefully}

긴 줄 자동 줄 바꿈을 참조하면 다음 줄로 보내십시오.

:set textwidth=0 
:set wrapmargin=0

12
일부 플러그인은이 설정을 무시하는 것 같습니다.
Yzmir Ramirez 2011

twwpI가 가야했다, 그래서 옵션은 정말 나를 위해 작동하지 않았다 formatoptions github.com/ain/.vim/blob/...
아인 Tohvri에게

2
tw와 wp가 여전히 문제를 해결하지 못한다면 SU에 대한이 게시물을 살펴보면 내 문제를 해결하는 데 도움이되었습니다 : superuser.com/questions/250112/…
Alien_SM

3
제거 filetype plugin on내에서 것은 .vimrc나를 위해 그것을했다.

1
이 답변을 사용 gq하면 단락을 텍스트 너비에 수동으로 재정렬하는 데 사용할 수 없습니다 . @Engineero가 올바른 것이어야합니다.
Dylanthepiguy

86

다른 답변 중 어느 것도 나를 위해 일하지 않았습니다 (IDK 이유).

:set wrap! 나를 위해 트릭을 수행했습니다 (Windows 용 GVim 사용).


8
이것은 약간 다른 문제를 해결합니다. wrap줄 바꿈 모양을 제공하지만 실제로 텍스트를 새 줄로 나누지 는 않습니다 . wrap활성화 했을 가능성이 있으므로 비활성화 :set wrap!했습니다. :set wrap?현재 값 (예 : wrap또는 nowrap)을 에코 할 것인지 확인할 수 있습니다 .
shadowtalker

1
이 솔루션은 Mac OsX에서 작동합니다. Vim 버전 7.4
Shnkc

이것은 나를 위해 일한 나는 변경 textwidth하고 wrapmargin처음 그러나 이것은 실제로 포장 선없이 갱신하고 다시 쓰게 정력을 강요했다.
Kredns

딩 딘 딩! neovim에서 작동
Gjaa

정말로 필요한 명령이 너무 표현력 있고 간단하다는 것을 알게 된 마법의 순간입니다. 개발자 감사합니다
Capitan Empanada

57

set formatoptions-=t 트릭을해야합니다. set formatoptions+=t자동 줄 바꿈을 다시 켭니다.

로 할 수있는 작업에 대한 자세한 내용 은 문서를formatoptions 참조하십시오 .


2
감사합니다! 귀하의 솔루션은 나를 위해 일한 유일한 솔루션입니다. 삽입 모드에 들어갈 때 더 이상 vim에서 줄 바꿈을 삽입하지 않습니다.
Geremia

2
예. 이것이 진정한 해결책입니다.
러스 베이트먼

16

vim이 긴 줄을 감싸는 것을 방지하기 위해 다음 두 줄을 사용합니다 .vimrc.

set nowrap           " do not automatically wrap on load
set formatoptions-=t " do not automatically wrap text when typing

12

줄 바꿈을 비활성화하려면 :set wrap!이 명령을 ~/.vimrc.


2
이것은이 질문에 관한 실제 줄 바꿈의 자동 삽입에 영향을 미치지 않습니다.
Arthur Tacca

9

설정 한 텍스트 너비 일 수 있으며, 특정 길이에 도달하면 자동으로 줄을 끊습니다.

:set tw=0

그것이 실패하면 예를 들어

:set wrap linebreak textwidth=0 

:set virtualedit=insert

2
줄 바꿈 및 줄 바꿈은 실제 줄 끝을 버퍼에 삽입하지 않으므로 그의 문제가 아닌 것 같습니다.
A. Levy


0

vimrc_example.vim (예, Vim74에있는 파일)을 열고 textwidth = 0을 설정합니다.


0

맥북 프로에서 나는 .vimrc 라인

autocmd FileType text setlocal textwidth=78

그래서 그것은되었다

"  autocmd FileType text setlocal textwidth=78

.

(homebrew를 통해 vim 버전을 설치했습니다.) 이것은 모든 .txt 파일에 도움이되었습니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.