In my .hgrc I can provide an editor or command to start the editor with commit parameters.
I want to write a method or alias that runs $ hg ci , it will not only open the message in Vim, but will also split the window and print $ hg diff .
I know that I can provide options for vim using the +{command} option. Thus, running $ vim "+vsplit" does the splitting, but any other parameters go to the first open window. Therefore, I assume that I need a specific function, but I have no experience writing my own Vim scripts.
The script should:
- Open a new vertical decay with an empty buffer (possibly
vnew ) - In an empty buffer run
:.!hg diff - Set an empty buffer file type as diff
:set ft=diff
I wrote a function like this:
function! HgCiDiff() vnew :.!hg diff set ft=diff endfunction
And in .hgrc I added an option: editor = vim "+HgCiDiff()"
This seems to work, but I would like the broken window to be on the right side (now it opens on the left), and the mercurial message will be a focused window. In addition :wq can be set as a temporary shortcut to :wq<CR>:q! (with the assumption that the mercury message is focused).
Any suggestions to make this a little more useful and less short?
UPDATE: I found a vim split guide , so changing vnew with rightbelow vnew opens diff on the right side.
source share