I'm trying to fully understand the following command in Vim:

:exe "grep -R " . shellescape(expand("<cWORD>")) . " ."<cr>

I got the use of expand function (force the expansion of into the actual string before it gets passed to shellescape) and shellescape command itself ( from Vim help page: Escape {string} for use as a shell command argument).

What I do not understand, from help itself either, is that use of dots, one before and one after shellescape command.

Again, both of the dots are preceeded and followed by an empty space. And if I use :

:exe "grep -R "shellescape(expand("<cWORD>"))" ."<cr>

which is the same command without those dots, I (apparently) get the same result.

Can anybody give a detailed explanation?

Thank you

  • It basically concatenates strings.
    – paradroid
    Nov 20, 2023 at 17:13

1 Answer 1


If you pass multiple strings to the :execute command it will join them together, adding a space between each string. The . operator concatenates strings without adding a space. In this command, adding an extra space won’t break it, so either way works fine. See :help :execute and :help expr-..

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.