Vim Tips Wiki
(Change to TipImported template + severe manual clean)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=1491
 
|id=1491
  +
|previous=1490
|title=Call TortoiseSVN commands from within Vim
 
  +
|next=1495
|created=January 26, 2007 11:31
+
|created=January 26, 2007
 
|complexity=basic
 
|complexity=basic
 
|author=Rex Kerr
 
|author=Rex Kerr
 
|version=5.7
 
|version=5.7
 
|rating=18/8
 
|rating=18/8
 
}}
|text=
 
Tortoise SVN is (IMO) the best Subversion GUI available. That said, it would be nice if you could launch the various commands from within Vim so that you don't have to go back to explorer to get the context menu. Here are some mappings that work on the current buffer.
+
Tortoise SVN is the best Subversion GUI available. That said, it would be nice if you could launch the various commands from within Vim so that you don't have to go back to Explorer to get the context menu. Here are some mappings that work on the current buffer.
   
  +
<pre>
 
" Save the current buffer and execute the Tortoise SVN interface's diff program
 
map &lt;silent&gt; ,tdiff :w&lt;CR&gt;:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:diff /path:"%" /notempfile /closeonend"&lt;CR&gt;
   
 
" Save the current buffer and execute the Tortoise SVN interface's log
 
map &lt;silent&gt; ,tlog :w&lt;CR&gt;:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:log /path:"%" /notempfile /closeonend"&lt;CR&gt;
   
" Save the current buffer and execute the Tortoise SVN interface's diff program
+
" Save the current buffer and execute the Tortoise SVN interface's revision graph
 
map &lt;silent&gt; ,trevs :w&lt;CR&gt;:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:revisiongraph epath:"%" /notempfile /closeonend"&lt;CR&gt;
   
 
" Save the current buffer and execute the Tortoise SVN interface's blame program
map &lt;silent&gt; ,tdiff :w&lt;CR&gt;:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:diff /path:"%" /notempfile /closeonend"&lt;CR&gt;
 
 
map &lt;silent&gt; ,tblame :call TortoiseBlame()&lt;CR&gt;
   
 
function! TortoiseBlame()
 
" Save the buffer
 
silent execute(':w')
 
" Now run Tortoise to get the blame dialog to display
 
let filename = expand("%")
 
let linenum = line(".")
 
silent execute('!C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:blame /path:"' . filename . '" /line:' . linenum . ' /notempfile /closeonend')
  +
endfunction
  +
</pre>
   
 
Others can be added very simply by using these as a template. The command line options are documented at http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-automation.html
   
 
==Comments==
" Save the current buffer and execute the Tortoise SVN interface's log
 
 
I use Vim from within bash on Windows XP and had to switch the path's to be more cygwin compliant. I also switched some of the double quotes to single quotes. Everything works great except that it takes forever to build my revision graph. Here's my slight changes. I also used a different mapping than above, but that just a preference of mine:
   
  +
<pre>
map &lt;silent&gt; ,tlog :w&lt;CR&gt;:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:log /path:"%" /notempfile /closeonend"&lt;CR&gt;
 
 
" Save current buffer and diff the file using Tortoise SVN
 
map &lt;unique&gt; &lt;silent&gt; &lt;leader&gt;td :w&lt;CR&gt;:silent !'/C/Program Files/TortoiseSVN/bin/TortoiseProc.exe' /command:diff /path:'%' /notempfile /closeonend&lt;CR&gt;
   
 
" Save current buffer and launch Tortoise SVN's revision graph
 
map &lt;unique&gt; &lt;silent&gt; &lt;leader&gt;tr :w&lt;CR&gt;:silent!'/C/Program Files/TortoiseSVN/bin/TortoiseProc.exe' /command:revisiongraph epath:'%' /notempfile /closeonend&lt;CR&gt;
   
 
" Save the current buffer and execute the Tortoise SVN interface's blame program
 
map &lt;unique&gt; &lt;leader&gt;tb :call TortoiseBlame()&lt;CR&gt;
   
" Save the current buffer and execute the Tortoise SVN interface's revision graph
+
" Save the current buffer and execute the Tortoise SVN interface's log
 
map &lt;unique&gt; &lt;silent&gt; &lt;leader&gt;tl :w&lt;CR&gt;:silent !'/c/Program Files/TortoiseSVN/bin/TortoiseProc.exe' /command:log /path:'%' /notempfile /closeonend&lt;CR&gt;
   
 
function! TortoiseBlame()
map &lt;silent&gt; ,trevs :w&lt;CR&gt;:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:revisiongraph epath:"%" /notempfile /closeonend"&lt;CR&gt;
 
 
" Save the buffer
 
silent execute(':w')
 
" Now run Tortoise to get the blame dialog to display
 
let filename = expand("%")
 
let linenum = line(".")
 
execute('!/C/Progra~1/TortoiseSVN/bin/TortoiseProc.exe /command:blame /path:' . filename . ' /line:' . linenum . ' /notempfile /closeonend')
  +
endfunction
  +
</pre>
   
 
 
" Save the current buffer and execute the Tortoise SVN interface's blame program
 
 
map &lt;silent&gt; ,tblame :call TortoiseBlame()&lt;CR&gt;
 
 
fu! TortoiseBlame()
 
 
" Save the buffer
 
 
silent execute(':w')
 
 
 
 
" Now run Tortoise to get the blame dialog to display
 
 
let filename = expand("%")
 
 
let linenum = line(".")
 
 
silent execute('!C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:blame /path:"' . filename . '" /line:' . linenum . ' /notempfile /closeonend')
 
 
endfunc
 
 
 
 
Others can be added very simply by using these as a template. The command line options are documented at:
 
 
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-automation.html
 
}}
 
 
== Comments ==
 
Hrm... my lines got split incorrectly, but I think that you can figure out how to fix them...
 
 
rexkerr--AT--gmail.com
 
, January 26, 2007 11:41
 
 
----
 
----
 
And for those who want to use Vim from Tortoise:
Great Tip! I use Vim from within bash on Windows XP and had to switch the path's to be more cygwin compliant. I also switched some of the double quotes to single quotes. Everything works great except that it takes forever to build my revision graph. Here's my slight changes. Fyi...I also used a different mapping than above, but that just a preference of mine:
 
   
 
Go to tortoisesvn, settings
" Save current buffer and diff the file using Tortoise SVN
 
map &lt;unique&gt; &lt;silent&gt; &lt;leader&gt;td :w&lt;CR&gt;:silent !'/C/Program Files/TortoiseSVN/bin/TortoiseProc.exe' /command:diff /path:'%' /notempfile /closeonend&lt;CR&gt;
 
   
 
Diff viewer : <tt>gvim -d %base %mine</tt>
" Save current buffer and launch Tortoise SVN's revision graph
 
map &lt;unique&gt; &lt;silent&gt; &lt;leader&gt;tr :w&lt;CR&gt;:silent!'/C/Program Files/TortoiseSVN/bin/TortoiseProc.exe' /command:revisiongraph epath:'%' /notempfile /closeonend&lt;CR&gt;
 
   
 
Merge Tool : <tt>gvim -c":tabnew %merged" -d %theirs %mine</tt>
" Save the current buffer and execute the Tortoise SVN interface's blame program
 
map &lt;unique&gt; &lt;leader&gt;tb :call TortoiseBlame()&lt;CR&gt;
 
   
" Save the current buffer and execute the Tortoise SVN interface's log
 
map &lt;unique&gt; &lt;silent&gt; &lt;leader&gt;tl :w&lt;CR&gt;:silent !'/c/Program Files/TortoiseSVN/bin/TortoiseProc.exe' /command:log /path:'%' /notempfile /closeonend&lt;CR&gt;
 
 
fu! TortoiseBlame()
 
" Save the buffer
 
silent execute(':w')
 
 
" Now run Tortoise to get the blame dialog to display
 
let filename = expand("%")
 
let linenum = line(".")
 
execute('!/C/Progra~1/TortoiseSVN/bin/TortoiseProc.exe /command:blame /path:' . filename . ' /line:' . linenum . ' /notempfile /closeonend')
 
endfunc
 
 
 
dsm26 [at] excite.com
 
, February 6, 2007 10:42
 
 
----
 
----
 
Nice tip!
 
 
And for those who want to use vim from Tortoise :
 
Go to tortoisesvn >> settings
 
 
Diff viewer : gvim -d %base %mine
 
 
Merge Tool : gvim -c":tabnew %merged" -d %theirs %mine
 
 
 
hth
 
 
gabrielware [at] free.fr
 
, August 22, 2007 16:14
 
----
 
<!-- parsed by vimtips.py in 0.531091 seconds-->
 
 
 
 
[[Category:VersionControl]]
 
[[Category:VersionControl]]

Revision as of 22:25, 1 January 2008

Tip 1491 Printable Monobook Previous Next

created January 26, 2007 · complexity basic · author Rex Kerr · version 5.7


Tortoise SVN is the best Subversion GUI available. That said, it would be nice if you could launch the various commands from within Vim so that you don't have to go back to Explorer to get the context menu. Here are some mappings that work on the current buffer.

" Save the current buffer and execute the Tortoise SVN interface's diff program
map <silent> ,tdiff :w<CR>:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:diff /path:"%" /notempfile /closeonend"<CR>

" Save the current buffer and execute the Tortoise SVN interface's log
map <silent> ,tlog :w<CR>:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:log /path:"%" /notempfile /closeonend"<CR>

" Save the current buffer and execute the Tortoise SVN interface's revision graph
map <silent> ,trevs :w<CR>:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:revisiongraph epath:"%" /notempfile /closeonend"<CR>

" Save the current buffer and execute the Tortoise SVN interface's blame program
map <silent> ,tblame :call TortoiseBlame()<CR>

function! TortoiseBlame()
  " Save the buffer
  silent execute(':w')
  " Now run Tortoise to get the blame dialog to display
  let filename = expand("%")
  let linenum = line(".")
  silent execute('!C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:blame /path:"' . filename . '" /line:' . linenum . ' /notempfile /closeonend')
endfunction

Others can be added very simply by using these as a template. The command line options are documented at http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-automation.html

Comments

I use Vim from within bash on Windows XP and had to switch the path's to be more cygwin compliant. I also switched some of the double quotes to single quotes. Everything works great except that it takes forever to build my revision graph. Here's my slight changes. I also used a different mapping than above, but that just a preference of mine:

" Save current buffer and diff the file using Tortoise SVN
map <unique> <silent> <leader>td :w<CR>:silent !'/C/Program Files/TortoiseSVN/bin/TortoiseProc.exe' /command:diff /path:'%' /notempfile /closeonend<CR>

" Save current buffer and launch Tortoise SVN's revision graph
map <unique> <silent> <leader>tr :w<CR>:silent!'/C/Program Files/TortoiseSVN/bin/TortoiseProc.exe' /command:revisiongraph epath:'%' /notempfile /closeonend<CR>

" Save the current buffer and execute the Tortoise SVN interface's blame program
map <unique> <leader>tb :call TortoiseBlame()<CR>

" Save the current buffer and execute the Tortoise SVN interface's log
map <unique> <silent> <leader>tl :w<CR>:silent !'/c/Program Files/TortoiseSVN/bin/TortoiseProc.exe' /command:log /path:'%' /notempfile /closeonend<CR>

function! TortoiseBlame()
  " Save the buffer
  silent execute(':w')
  " Now run Tortoise to get the blame dialog to display
  let filename = expand("%")
  let linenum = line(".")
  execute('!/C/Progra~1/TortoiseSVN/bin/TortoiseProc.exe /command:blame /path:' . filename . ' /line:' . linenum . ' /notempfile /closeonend')
endfunction

And for those who want to use Vim from Tortoise:

Go to tortoisesvn, settings

Diff viewer : gvim -d %base %mine

Merge Tool : gvim -c":tabnew %merged" -d %theirs %mine