Vim Tip: Restore cursor’s last position

Here’s a useful vi trick that turned out to be a real time saver. It’s a set of commands you add to your vimrc file (on windows) that will recover the cursor’s last position when the file was last closed. The original tip was found on the vim wikia, which is full of those very useful vim tricks. Give it a try!

" Tell vim to remember certain things when we exit
"  '10 : marks will be remembered for up to 10 previously edited files
"  "100 : will save up to 100 lines for each register
"  :20 : up to 20 lines of command-line history will be remembered
"  % : saves and restores the buffer list
"  n... : where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.viminfo
 
" when we reload, tell vim to restore the cursor to the saved position
augroup JumpCursorOnEdit
 au!
 autocmd BufReadPost *
 \ if expand("<afile>:p:h") !=? $TEMP |
 \ if line("'\"") > 1 && line("'\"") <= line("$") |
 \ let JumpCursorOnEdit_foo = line("'\"") |
 \ let b:doopenfold = 1 |
 \ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
 \ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
 \ let b:doopenfold = 2 |
 \ endif |
 \ exe JumpCursorOnEdit_foo |
 \ endif |
 \ endif
 " Need to postpone using "zv" until after reading the modelines.
 autocmd BufWinEnter *
 \ if exists("b:doopenfold") |
 \ exe "normal zv" |
 \ if(b:doopenfold > 1) |
 \ exe "+".1 |
 \ endif |
 \ unlet b:doopenfold |
 \ endif
augroup END

Creating a Tip Jar on WordPress with Paypal

I’ve been curious to know how to setup the equivalent of a Tip Jar on my website. Just for the fun of it. I finally got to it, and I thought I should share the wealth by writing this simple tutorial on how to create a Tip Jar using your existing PayPal account.

  1. Go to http://www.paypal.com and login to your account (Sign up for one if you don’t have one)
  2. Click on ‘Merchant Tools’
  3. Find the link to ‘Donations’ at the right side by scrolling down a little (or do a search for Donations).
  4. Fill out the necessary information and click on ‘Create Button Now’
  5. You then copy it to your website, and hope for some more traffic!
  6. Don’t forget to leave a tip by clicking on my ‘Make a Donation’ button to see if my setup works and help improve my site (Ha ha!).
© Copyright Bonuel Photography - Theme by Pexeto