Vim Tips Wiki

Go to alternate file or next file if no alternate

Redirected from VimTip1023

1,625pages on
this wiki
Add New Page
Talk0 Share
Tip 1023 Printable Monobook Previous Next

created October 23, 2005 · complexity intermediate · author Yakov Lerner · version 6.0

" Ctrl-^ is very handy command in normal mode. Ctrl-^
" switches to "alternate file". When there is no "alternate file",
" I wanted Ctrl-^ to jump to next file in the list.
" Insert following commands into your vimrc, then
" Ctrl-^ will be enhanced so that when there is no alternate file
" but there is next file, it will jump to the next file.
" My remapping of <C-^>. If there is no alternate file, then switch to next file.
function! MySwitch()
  if expand('#')=="" | silent! next
    exe "normal! \<c-^>"
map <C-^> :call MySwitch()<CR>


Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.