Vim Tips Wiki
(Move categories to tip template)
(Adjust previous/next navigation)
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
 
{{TipImported
 
{{TipImported
 
|id=1023
 
|id=1023
|previous=1022
+
|previous=1021
 
|next=1025
 
|next=1025
 
|created=October 23, 2005
 
|created=October 23, 2005
Line 19: Line 19:
 
" Ctrl-^ will be enhanced so that when there is no alternate file
 
" Ctrl-^ will be enhanced so that when there is no alternate file
 
" but there is next file, it will jump to the next 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.
+
" My remapping of <C-^>. If there is no alternate file, then switch to next file.
 
function! MySwitch()
 
function! MySwitch()
 
if expand('#')=="" | silent! next
 
if expand('#')=="" | silent! next
 
else
 
else
exe "normal! \&lt;c-^&gt;"
+
exe "normal! \<c-^>"
 
endif
 
endif
 
endfu
 
endfu
map &lt;C-^&gt; :call MySwitch()&lt;cr&gt;
+
map <C-^> :call MySwitch()<CR>
 
</pre>
 
</pre>
   
 
==Comments==
 
==Comments==
 
----
 

Latest revision as of 10:16, 12 April 2009

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
  else
    exe "normal! \<c-^>"
  endif
endfu
map <C-^> :call MySwitch()<CR>

Comments[]