Permalink
Browse files

Version 1.3: Initial upload

  • Loading branch information...
0 parents commit 453c70c8cd9e52f82f63ef2f87e0ef0e62ce3fb3 @joeytwiddle joeytwiddle committed with Oct 24, 2012
Showing with 46 additions and 0 deletions.
  1. +15 −0 README
  2. +31 −0 plugin/back_to_recent_buffer.vim
15 README
@@ -0,0 +1,15 @@
+This is a mirror of http://www.vim.org/scripts/script.php?script_id=4290
+
+Sometimes I use Ctrl-] a few times to read some code, perhaps navigating up
+and down in the files I visit. Then I want to get back to where I was
+before, but Ctrl-O may require a lot of hits.
+
+Here we introduce an alternative, that goes back to the previous file, not
+the previous position. The default mapping is on C-U.
+
+If you would rather go back to the last piece of code you were editing, see
+last_edit_marker.vim
+
+BUG TODO: If there is no previous buffer, will loop forever! We could check
+to see if we don't move at all, then abort.
+
@@ -0,0 +1,31 @@
+" Sometimes I use Ctrl-] a few times to read some code, perhaps navigating up
+" and down in the files I visit. Then I want to get back to where I was
+" before, but Ctrl-O may require a lot of hits.
+"
+" Here we introduce an alternative, that goes back to the previous file, not
+" the previous position. The default mapping is on C-U.
+"
+" If you would rather go back to the last piece of code you were editing, see
+" last_edit_marker.vim
+
+" BUG TODO: If there is no previous buffer, will loop forever! We could check
+" to see if we don't move at all, then abort.
+function GoBackToRecentBuffer()
+ let startName = bufname('%')
+ while 1
+ normal! 
+ let nowName = bufname('%')
+ if nowName != startName
+ break
+ endif
+ endwhile
+endfunction
+
+" A bit much to override an important key?
+"nnoremap <silent> <C-O> :call GoBackToRecentBuffer()<Enter>
+" You can always use <C-I> if you need to go forwards again.
+" I never use this one:
+nnoremap <silent> <C-U> :call GoBackToRecentBuffer()<Enter>
+" You can use g; and g, to move between recent change points.
+"" Only in GVim:
+"nnoremap <silent> <C-BS> :call GoBackToRecentBuffer()<Enter>

0 comments on commit 453c70c

Please sign in to comment.