How to stop line breaking in vim

前端 未结 11 2046
执笔经年
执笔经年 2020-12-12 10:06

I like that the long lines are displayed over more than one terminal line; I don’t like that vim inserts newlines into my actual text. Which part of .vimrc I should change?

11条回答
  •  孤街浪徒
    2020-12-12 10:48

    If, like me, you're running gVim on Windows then your .vimrc file may be sourcing another 'example' Vimscript file that automatically sets textwidth (in my case to 78) for text files.

    My answer to a similar question as this one – How to stop gVim wrapping text at column 80 – on the Vi and Vim Stack Exchange site:

    In my case, Vitor's comment suggested I run the following:

    :verbose set tw?
    

    Doing so gave me the following output:

    textwidth=78
          Last set from C:\Program Files (x86)\Vim\vim74\vimrc_example.vim
    

    In vimrc_example.vim, I found the relevant lines:

    " Only do this part when compiled with support for autocommands.
    if has("autocmd")
    
      ...
    
      " For all text files set 'textwidth' to 78 characters.
      autocmd FileType text setlocal textwidth=78
    
      ...
    

    And I found that my .vimrc is sourcing that file:

    source $VIMRUNTIME/vimrc_example.vim
    

    In my case, I don't want textwidth to be set for any files, so I just commented out the relevant line in vimrc_example.vim.

提交回复
热议问题