1

Using neovim (v0.8.1 on Fedora 37) with its default configuration in my home directory, when I type :e <tab> the completion menu pops up, the first entry (here Desktop) is highlighted and the command line reads :e Desktop/. Say I am looking for Desktop/foo.txt. Intuitively I would like to hit Enter to accept the suggestion, then hit tab again to list the contents of Desktop (this is the default behavior of the fish shell). However, when I hit Enter neovim immediatly executes the command and starts editing the Desktop directory.

Is there a way to only close the completion popup when I press Enter (emulating <C-y>) and of course still accept the command on Enter when there is no completion popup?

1 Answer 1

1

I found this solution that gives the exact behavior I described:

-- init.lua
vim.keymap.set("c", "<cr>", function()
  if vim.fn.pumvisible() == 1 then return '<c-y>' end
  return '<cr>'
  end, { expr = true })

Your Answer

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

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