Say I have 4 files in current directory:


Next, I want to save current buffer to a new file file-foo-03.txt. So I enter :w f and then press Tab for a few times until the cmdline becomes :w file-foo-01.txt:

enter image description here

Then, I want to use to move cursor to 1 and change it to 3. But if I press it'll behave like Shift-Tab and the previous file file-bar-02.txt is selected and the cmdline becomes :w file-bar-02.txt:

enter image description here

So how can I ask and to move cursor rather than cycle through the file completion candidates?

2 Answers 2


Use Ctrl-Y (as a mnemotechnic reminder I think of it as Ctrl-"Yes" to validate the selection)

When you use Ctrl-Y in a selection menu it chooses the selection but does not launch the command line

After the filename that pleases you most is selected/validated, you can now edit the filename using Left and Right and change it to your taste


Found the answer in :help wildmenu:

While the menu is active these keys have special meanings:

  • CTRL-Y - accept the currently selected match and stop completion.
  • CTRL-E - end completion, go back to what was there before selecting a match.
  • Left / Right - select previous/next match (like CTRL-P / CTRL-N)
  • Down - in filename/menu name completion: move into a subdirectory or submenu.
  • CR - in menu completion, when the cursor is just after a dot: move into a submenu.
  • Up - in filename/menu name completion: move up into parent directory or parent menu.

If you want Left and Right to move the cursor instead of selecting a different match, use this:

  :cnoremap <Left>  <Space><BS><Left>
  :cnoremap <Right> <Space><BS><Right>

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.