" Vim plugin -- last-position-jump improved (esp. for Easy Vim) " File: lastpos.vim " Created: 2010 Mar 24 " Last Change: 2010 Mar 31 " Rev Days: 3 " Author: Andy Wokula " " TODO " + how can we be sure that =... will be executed in Insert mode? " ! use intermediate LastPos " + why is :normal! g`" wrapped with :exec? " ! once the code was a one-liner " + use this assumption: " if not present, Vim will initialize the '"'-mark with [0,1,1,0] " :au BufReadPost * echomsg string(getpos("'\"")) " + don't move the cursor if another plugin already moved it " + don't move the cursor for special buffers (buftype not empty) [1] " [1] added, although jumping to help tags seems to work without this " guard map LastPos cmap LastPos ino LastPos =''[setpos('.',getpos("'\""))] augroup LastPos au! BufReadPost * call s:LastPos(&insertmode) augroup END func! s:LastPos(mode) if a:mode == 2 au! LastPos InsertEnter call feedkeys("\LastPos") return endif let m = "'\"" if getpos(m) != [0,1,1,0] && line(m) <= line("$") \ && getpos(".") == [0,1,1,0] \ && &buftype == "" if a:mode == 1 au LastPos InsertEnter * call s:LastPos(2) else normal! g`" endif endif endfunc " vim:et tw=72: