From 117c86a662544ac54eff555681b435712952e6a6 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 5 Nov 2019 14:35:31 +0100 Subject: Toggle word wrap mode with w. --- vimrc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'vimrc') diff --git a/vimrc b/vimrc index 9427356..cc42079 100644 --- a/vimrc +++ b/vimrc @@ -34,3 +34,37 @@ noremap gj " toggle nerdtree with ctrl-o map :NERDTreeToggle + +" Toggle word-wrap mode +" This will also fix movement keys so they move by visual +" lines instead of physical lines in word-wrap mode. +" See https://vim.fandom.com/wiki/Move_cursor_by_display_lines_when_wrapping +noremap w :call ToggleWrap() +function ToggleWrap() + if &wrap + echo "Wrap OFF" + setlocal nowrap + set virtualedit=all + silent! nunmap + silent! nunmap + silent! nunmap + silent! nunmap + silent! iunmap + silent! iunmap + silent! iunmap + silent! iunmap + else + echo "Wrap ON" + setlocal wrap linebreak nolist + set virtualedit= + setlocal display+=lastline + noremap gk + noremap gj + noremap g + noremap g + inoremap gk + inoremap gj + inoremap g + inoremap g + endif +endfunction -- cgit v1.2.3