Vim toggle word-wrap

Updated: 23 May 2023

function ToggleWrap()
    if (&wrap == 1)
        set nowrap nolinebreak
    else
        set wrap linebreak
    endif
endfunction

map <leader>w :call ToggleWrap()<CR>

Leave a comment