VIM: Perform two actions at once

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.

Answers


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

:w|!svn commit -m foo

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')

@JoshLee gives the literal answer. However, why is a keybinding unacceptable to you?

nnoremap <Leader>s :w<bar>!svn commit -m<space>

will still let you write your commit message before you push Enter...


Need Your Help

Extend a LINQ entity-class with constructor methods and make that entity-class inherit from it's DataContext class

linq-to-sql .net-3.5 c#-3.0

Is it possible to extend LINQ-to-SQL entity-classes with constructor-methods and in the same go; make that entity-class inherit from it's data-context class?--In essence converting the entity-class...

Highlight a particular plot among multiple plots

r plot ggplot2

I've made a plot using a data frame and ggplot. Here's the plot for example