Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 453c70c
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |