cursorposition.vim 936 B

123456789101112131415161718192021222324252627282930313233343536
  1. " Cursor Position - Modeline and Notes {{{
  2. " vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{{,}}} foldlevel=0 foldmethod=marker spell:
  3. "
  4. " cinaeco/dotfiles Cursor Position from last editing session.
  5. "
  6. " Taken from spf13-vim.
  7. "
  8. " }}}
  9. " Cursor Autocommands {{{
  10. if has("autocmd")
  11. " Restore Position {{{
  12. " http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
  13. " Restore cursor to file position in previous editing session
  14. function! ResCur()
  15. if line("'\"") <= line("$")
  16. normal! g`"
  17. return 1
  18. endif
  19. endfunction
  20. augroup resCur
  21. autocmd!
  22. autocmd BufWinEnter * call ResCur()
  23. augroup END
  24. " }}}
  25. " Git Commit Exception{{{
  26. " Instead of reverting the cursor to the last position in the buffer, we
  27. " set it to the first line when editing a git commit message
  28. au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
  29. " }}}
  30. endif
  31. " }}}