10 years ago
Jumps to the last known position, but only when that position is deemed "sane". For instance, ignores git buffers, since they generally represent transient files such as commit messages and rebase scripts.
function! s:JumpToLastKnownCursorPosition() if line("'\"") <= 1 | return | endif if line("'\"") > line("$") | return | endif " Ignore git commit messages and git rebase scripts if expand("%") =~# '\(^\|/\)\.git/' | return | endif execute "normal! g`\"" | endfunction autocmd BufReadPost * call s:JumpToLastKnownCursorPosition()
Martínez Ortiz Saúl Axel 6 years ago
Someone explain how can the line be less than one or more than the last line.