Why can't I stop vim from wrapping my code?

前端 未结 9 1879
陌清茗
陌清茗 2020-12-12 12:05

I can\'t stop vim from wrapping my Python code. If I enter :set nowrap like a champ, but it still wraps.

I can hit J to unite the split lines

相关标签:
9条回答
  • 2020-12-12 12:46

    Maybe it's the textwidth that's set, which automatically breaks lines when it reaches a certain length Try

    :set tw=0
    

    If that fails play with e.g.

    :set wrap linebreak textwidth=0 
    

    and

    :set virtualedit=insert
    
    0 讨论(0)
  • 2020-12-12 12:48

    set formatoptions-=t should do the trick. set formatoptions+=t will turn auto-wrapping back on.

    For more information on what you can do with formatoptions, see the docs.

    0 讨论(0)
  • 2020-12-12 12:49

    On macbook pro I outcommented in .vimrc the line

    autocmd FileType text setlocal textwidth=78
    

    so it became

    "  autocmd FileType text setlocal textwidth=78
    

    .

    (I installed a version of vim via homebrew.) This helped for all .txt files.

    0 讨论(0)
  • 2020-12-12 12:51

    Open vimrc_example.vim (Yes, this is the file in Vim74) and set textwidth=0.

    0 讨论(0)
  • 2020-12-12 12:52
    '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}
    

    If you refer to auto wrapping of long lines sending them to the next one, try

    :set textwidth=0 
    :set wrapmargin=0
    
    0 讨论(0)
  • 2020-12-12 13:04

    To disable line wrap, you can enter :set wrap! or append this command to your ~/.vimrc.

    0 讨论(0)
提交回复
热议问题