편집 중에 vim 텍스트 너비를 수정하는 방법은 무엇입니까?

편집 중에 vim 텍스트 너비를 수정하는 방법은 무엇입니까?

.vimrc에서 tw=80으로 제한한 파일을 편집할 때 나중에 편집하러 다시 돌아오면 줄 길이가 여기저기서 발생합니다. 예를 들어

lets say for the sake of argument that this line hits 80 characters
there and continues on the next line as normal

편집한 후...

lets say for the sake of argument (edit edit edit edit) that this 
line hits 80 characters
there and continues on the next line as normal

대신에

lets say for the sake of argument (edit edit edit edit) that this 
line hits 80 characters there and continues on the next line as 
normal

이 행동을 고치기 위해 내가 무엇을 할 수 있는지 아는 사람이 있나요?

답변1

" " 일반 모드 명령을 사용하여 텍스트 서식을 다시 지정할 수 있습니다 gq. 시각적 선택이나 모션으로 작동합니다. 예를 들어, ap"단락"(커서가 있는 현재 단락)을 의미하는 텍스트 개체 " "(모션 대신 ​​사용할 수 있음)를 사용할 수 있습니다 .

gqap

또는 서식을 다시 지정할 단락을 시각적으로 선택하고 " gq"만 입력할 수도 있습니다.

또 다른 비결은 'formatoptions' 옵션에 "a"와 선택적으로 "w"를 추가하는 것입니다:

:set formatoptions+=aw

이렇게 하면 " "를 사용할 필요 없이 입력할 때 단락 형식이 자동으로 다시 지정됩니다 gq.

보다:

:help gq
:help auto-format
:help 'formatoptions'
:help motion.txt

답변2

당신이 찾고있는 것은 vi 형식 옵션입니다. 텍스트 줄 바꿈을 켜려면 다음을 수행하십시오.

:set fo+= t

출처:

ftp://ftp.vim.org/pub/vim/doc/book/vimbook-OPL.pdf

http://blog.ezyang.com/2010/03/vim-textwidth/

관련 정보