Vim scripting: Preserve cursor position and screen view in function call

前端 未结 5 973
庸人自扰
庸人自扰 2021-02-02 11:11

I have some Vim functions that make changes to the document format. When I call this function, I currently use something like the following to save and restore my cursor positio

5条回答
  •  南旧
    南旧 (楼主)
    2021-02-02 11:32

    Just :h getpos()

    let save_cursor = getpos(".")
    " MoveTheCursorAround
    call setpos('.', save_cursor)
    

提交回复
热议问题