Closed jordwalke closed 9 years ago
Hi, I have the same issue (vim 7.3 and 7.4), I did not manage to fix ocp-indent.vim
but I found a temporary hack to put in one's .vimrc
:
map <silent> u :call MyUndo()<CR>
function MyUndo()
let _view=winsaveview()
:undo
call winrestview(_view)
endfunction
map <silent> <c-r> :call MyRedo()<CR>
function MyRedo()
let _view=winsaveview()
:redo
call winrestview(_view)
endfunction
hope it helps!
Unfortunately, that also resets the cursor position for other undo/redos that actually should move the cursor position.
you're right the hack is far too greedy
I've been trying https://github.com/def-lkb/ocp-indent-vim
(instead of the .vim
provided by ocp-indent)
it seems to work very well (it depends on Python and on other files installed with merlin)
it depends on Python and on other files installed with merlin
Actually, from what I can see the latest version only depends on python; the "magic" that was to be done by vimbufsync has been removed.
What is the difference between the two? Why are they named the same thing?
I just tried that repo, and it works great. How can we get people to use it instead of whatever comes directly out of OPAM?
Actually, if there are now no further dependencies than Python, it may well be ok to integrate def-lkb/ocp-indent-vim into ocp-indent/tools for easier installation. If that sounds ok ?
https://github.com/def-lkb/ocp-indent-vim has been working wonderfully for me, btw (with the following config):
function! Preserve(command)
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
execute a:command
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
nmap <D-M> :call Preserve("normal gg=G")<CR>
Even if only indenting a visually selected range, undoing an indentation (that was originally caused by
=
) causes the cursor to move to the top of the file.