11

I'm currently trying to create the following mapping in my vimrc:

nnoremap <Leader>s :split

The :split is followed by a trailing space. This makes sense so I can enter the file name without always manually preceding it with a space. This code works in fact. However, it's not very nice from a readability perspective because it's not obvious that there's a space at the end of the mapping. It would be nice if there were a way to express the second part of the mapping as a string.

I'm not very experienced with vimscript, but I tried enclosing the second part of the mapping in double-quotes, single-quotes, and backticks, none of which result in a working mapping. Like I said, the mapping currently works as desired with the trailing space. But I would prefer a more programmer-friendly way of expressing the second part of the mapping. How can this be done?

1 Answer 1

14

I think your best option is to use <Space>:

nnoremap <Leader>s :split<Space>

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.