Make vim to remember file cursor position : solaris

Some time back, I installed vim in Solaris after taking the package from sunfreeware site. I have configured colors also. But one main annoying thing is that it does not remember the cursor position of the same file opened previously. i.e. When I open a file and move to line no:1000 , quit and open the same file again, cursor will be placed at line no:0. After reading a few web pages [not with much help], I have read vim documentation [:help viminfo]. There I found that by typing `” [backquote & doublequote], cursor will be moved to the line where we left last time. But I dont want to type `” everytime I open a file. I want to automate this. After searching for `” pattern in my Linux vim config files, I found the following code snippet in /etc/vimrc in my SuSE.

if has(“autocmd”)
autocmd BufReadPost *
\ if line(“‘\””) > 0 && line(“‘\””) <= line(“$”) |
\ exe “normal g`\”” |
\ endif
endif

After I have added the above code in my solaris .vimrc, things began working properly. Actually I have sent a mail to vim mailing list and started working on this problem. When I checked my mails after solving the problem, I saw few good replies from vim mailing list pointing to these links tip#80 , yahoo_groups .

Advertisements