0

I use set nowrap option in my config file, but when I open a file in a vertical split it has no effect.

If I redo set nowrap after open the file (in the split windows) it takes effect

Why? I try with vim and neovim with the same result.

Step to reproduce:

  1. set nowrap
  2. :vs
  3. open a file with long lines
2

The answer is in the doc :h 'wrap':

'wrap'          boolean (default on)
                local to window

The option is local to a window so setting it in your vimrc has no effect to your windows.

You probably want to set the option for a specific file type either in an autocommand :h autocmd

augroup NoWrap
    autocmd!
    autocmd Filetype markdown set nowrap
augroup END

or (and this is a better solution) in a ftplugin :h ftplugin

1
  • For me the better solution is open all file with nowrap so I set autocmd Filetype * set nowrap in vimrc file Apr 2 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.