How to Toggle Word Wrapping in Vim

The aim of this pageđź“ť is to explain text and word wrapping in Vim based on the particular example of enabling wrapping for Markdown files.

Pavol Kutaj
Feb 27, 2024
  • To toggle text wrapping in Vim:
:set wrap!
  • To toggle word wrapping in Vim:
:setlocal linebreak
  • To create a shortcut to toggle word and text wrapping in Vim for Markdown files, put the following into .vimrc
autocmd FileType markdown nnoremap <silent> <F2> :setlocal wrap! linebreak!<CR>

--

--

No responses yet