I want to use word completion in Ex mode, similar to using Ctrl-N in Insert mode to complete the current word.

Suppose, I want to do a substitution: :%s/<pattern>/<replacement>/gc. If the cursor is on the word to substitute, I could use C-R C-W to paste it into Ex mode (command-line). However, sometimes the cursor is far away from the word to substitute, and here word completion would be beneficial.

1 Answer 1


Not exactly what you want, but you can get insert-like completion in Command-line window, which is opened with q:. Just add b option to complete in your .vimrc, so vim will scan all opened buffers.

:set complete+=b


:h cmdline-window
:h 'complete'
  • Thank you. cmdline-window is Ex mode too, right? It’s just a window, instead of a single cmdline.
    – Shuzheng
    Jul 24, 2020 at 5:18
  • How do I see the :h for the proper version of complete? If I do :h complete, then I get help for a function complete({startcol}, {matches}).
    – Shuzheng
    Jul 24, 2020 at 6:52
  • Surround complete with single quotes like in answer.
    – Dmitry
    Jul 24, 2020 at 10:45
  • Yes, cmdline-window allows you switch modes and execute command on Enter key press. Also it shows commands history, so you can search easy with /
    – Dmitry
    Jul 24, 2020 at 10:51

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.