vim-anywhere icon indicating copy to clipboard operation
vim-anywhere copied to clipboard

Any reason to don't set filetype to some value?

Open vitalk opened this issue 10 years ago • 6 comments

Any way to set default filetype for new files? For example, I mostly use vim-anywhere to write in markdown and need to set ft=markdown any time a new Vim window opened.

For now I use the custom autocommand in my .vimrc to force set filetype for vim-anywhere files:

augroup ft_vim_anywhere
  au!
  au BufNewFile,BufRead **/vim-anywhere/doc-** setl ft=markdown
augroup END

Why not set filetype to text or markdown by default?

vitalk avatar Sep 16 '14 18:09 vitalk

Hey, I've definitely thought about this. I was going back and forth between adding a config file for vim-anywhere or finding a simple way to set this up by having vim anywhere read something set in the user's Vim config file whenever it's started.

I stayed away from setting defaults initially to keep the defaults from getting in anyone's way. Like if I default to markdown and you are trying to write something else, the fact that the filetype is markdown could cause unwanted highlighting and formatting. I figured nothing is better than something you might not want.

Thats a neat trick though. I may do add that to the readme eventually. I'll leave this open as a feature request if.

cknadler avatar Feb 15 '15 03:02 cknadler

Thanks for the detailed reply.

Note about configuration. Please, don't reinvent the wheel. The Vim has a built-in way to configure all the things (.vimrc). Think, how would Vim look like if any plugin and extension (I think about vim-anywhere more as a Vim extension then a simple wrapper) has its own config in a separate file. Each vimmer has a own, lovely organized .vimrc, and the best thing you can do is to forward them to the right direction. I mean, add a separate section about vim-anywhere configuration into the readme.

Best regards.

vitalk avatar Feb 15 '15 07:02 vitalk

Thats a good point. I wonder if there is some way to make it easier to identify vim-anywhere editing in .vimrc? I'll take another look and see if I can find anything.

cknadler avatar Jan 12 '16 04:01 cknadler

You could set a variable from the command line, then one could set the file type and other configuration in vimrc based on that.

omeid avatar Feb 17 '18 01:02 omeid

how about setting filetype to vim-anywhere? (e.g. by adding --cmd 'set filetype=vim-anywhere' to the commandline) afaik that should behave like default if the user didn't added any config, but they can detect it if wanted

nimaje avatar Feb 17 '18 09:02 nimaje

@nimaje @omeid Happy to discuss a pull request that adds this functionality. Probably won't get around to implementing myself.

cknadler avatar Feb 17 '18 18:02 cknadler