1

If I want to set the filetype manually in vim, I would like to tab complete filetypes vim recognizes. However, right now vim just inserts a literal ^I

:set ft=markd^I

Is this possible?

4

AFAIK, we cannot add completion to standard commands.

You'll have to define your own :SetFT command and complete with -complete=filetype Something like:

" untested
command! -nargs=1 -complete=filetype SetFt :set ft=<args>
  • 1
    That's too bad. I'd like to stick with the default command and would rather try to ask a vim developer to support it. But I guess this won't happen. Thanks for your answer! – Hotschke Oct 25 '17 at 10:34
  • 4
    Honestly, there is no reason it can't be done. You can try to open a Feature Request issue on vim github. Who knows? – Luc Hermitte Oct 25 '17 at 10:48
2

Builtin command :setfiletype

For setting the filetype there is additionally a dedicated vim command :setfiletype which supports tab completion and <C-d>:

:setfiletype mar<tab>
:setfiletype <C-d>

The command can be abbreviated as following:

:setf mar<tab>
:setf <C-d>

Plugin fzf.vim

The plugin fzf.vim provides furthermore the command :Filetypes.

:Filet[ypes]<CR>
> prompt

At the prompt you can enter a filetype with fuzzy matching e.g. mkd for markdown or jsc for javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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