I have a very long vimrc mapping to deal with for example

nnoremap <space>e :exe "!tmux send-keys -t.- 'cd $TEST' Enter"<Cr> :exe "!tmux send-keys -t.- 'source $TEST_NT/bin/activate' Enter"<Cr>

how can I break this long line into several short lines so that I can see everything in one screen

Something like the following style:

 nnoremap <space>e 
     :exe "!tmux send-keys -t.- 'cd $TEST' Enter"<Cr> 
     :exe "!tmux send-keys -t.- 'source $TEST_NT/bin/activate' Enter"<Cr> 

1 Answer 1


You can split your long line by inserting a Vim line continuation character (backslash) at the beginning of each continued line:

nnoremap <space>e 
       \ :exe "!tmux send-keys -t.- 'cd $TEST' Enter"<Cr> 
       \ :exe "!tmux send-keys -t.- 'source $TEST_NT/bin/activate' Enter"<Cr>

This is explained here: :help line-continuation. You should note the comment on leading whitespace, i.e.:

All leading whitespace characters in the line before a backslash are ignored.
Note however that trailing whitespace in the line before it cannot be inserted freely; it depends on the position where a command is split up whether additional whitespace is allowed or not.

  • 1
    You beat me by a couple of seconds. If you add the VimDoc link, then I'll delete my answer. Sep 6, 2018 at 6:45
  • 1
    @KarlYngveLervåg: Hmm, hmm. I am reluctant to add a link to online documentation. If I did that now, I would have to do that forever, and I simply dread the effort. I expect you to answer "fair enough" ;-).
    – nst0022
    Sep 6, 2018 at 10:57
  • 1
    I saved you the work. Sep 6, 2018 at 11:40
  • 2
    Fair enough :-).
    – nst0022
    Sep 6, 2018 at 14:47
  • 1
    I was getting issues with additional wrapped lines beginning with \ :. This was fine for the first wrapped line, but for others this meant a space was being added and my cursor would move forwards. I therefore had to have \: at the beginning of all but one of the lines, instead.
    – Alex W
    Jan 15, 2022 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.