From 68929a5ae83de6c083c807d51bd4a57e948acf23 Mon Sep 17 00:00:00 2001 From: lhark Date: Mon, 1 Apr 2019 14:31:05 -0400 Subject: [PATCH] [vim] Stabilize cursor while reflowing paragraph --- vimrc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vimrc b/vimrc index c798a8a..7ae21fc 100644 --- a/vimrc +++ b/vimrc @@ -170,7 +170,7 @@ nnoremap // :nohlsearch map Q gq "[Reflow current paragraph]" "[http://stevelosh.com/blog/2010/09/coming-home-to-vim/]" -nnoremap q gqip +nnoremap q :call ReflowParagraph() " http://stackoverflow.com/questions/1005/getting-root-permissions-on-a-file-inside-of-vi cmap w!! w !sudo tee >/dev/null % "[To disable the arrow keys]" @@ -200,7 +200,13 @@ if &t_Co > 2 || has("gui_running") " Revert with ":unlet c_comment_strings". let c_comment_strings=1 endif -" + +"[Reflow current paragraph]" +function! ReflowParagraph() + let l:view = winsaveview() + normal gqip + call winrestview(l:view) +endfunction "[Remove tabs and spaces at the end of lines]" function! DeleteTrailingTWS() if &ft =~ 'diff'