Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM: Perform two actions at once

Tags:

vim

I often save :w and commit to SVN svn commit -m "Ticket 351" as two operations. Is there a way to combine them into a single operation so that I might just :Enter when the need arises? I don't want to map a key as I will sometimes have to change the commit message.

Thanks.

like image 972
dotancohen Avatar asked Jan 17 '23 23:01

dotancohen


2 Answers

Use | as a command separator (see :help :bar):

:w|!svn commit -m foo
like image 104
Josh Lee Avatar answered Jan 24 '23 11:01

Josh Lee


You could also write a function. E.g. something like;

function! Commit(msg)

    write

    let response = system('svn commit -m "' . a:msg . '"')

    echo response

endfunction

Then later:

:call Commit('ticket 1234')
like image 41
Rory Hunter Avatar answered Jan 24 '23 11:01

Rory Hunter