cursorposition.vim 566 B

123456789101112131415
  1. if has("autocmd")
  2. " Restore Position
  3. " Based on the last-position mark '"'. Go to it if it is not the first line,
  4. " and if it is valid i.e. within the number of lines in the file.
  5. " From `:help line()`
  6. au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
  7. " Git Commit Exception
  8. " Instead of reverting the cursor to the last position in the buffer, we
  9. " set it to the first line when editing a git commit message
  10. au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
  11. endif
  12. " }}}