Questions tagged [filetype]

Questions about making Vim to have a defined behavior according the type of the edited file.

Filter by
Sorted by
Tagged with
3
votes
0answers
74 views

Filetype changes when using :split and :Explore

Why does using :split and :Explore cause the filetype to change? For example, edit a file named text.man, and the filetype is set to man. Change the filetype to txt, then :split and :Explore in the ...
17
votes
3answers
2k views

Blocking changes to read only file

When using Vim to edit a read only file it will just provide a warning the first time it is edited but allow any changes to take place. I can understand this behaviour could be useful for someone ...
1
vote
1answer
141 views

`filetype plugin on` and square brackets

With this .vimrc: nnoremap [ :lp^M nnoremap ] :lne^M filetype plugin on vim becomes sluggish when switching between "errors" of location list with square brackets. As opposed to using lprevious/...
10
votes
2answers
1k views

Use single ftplugin for more than one filetype

I have an ftplugin under &runtimepath/ftplugin/c.vim which sets all my preferred options for c files. However, I would also like to use the same settings for cpp files. I could just copy the ...
5
votes
1answer
3k views

Filetype that LaTeX should be

From :help filetype: If the first line of a *.tex file has the form %&<format> then this determined the file type: plaintex (for plain TeX), context (for ConTeXt), or tex (for ...
3
votes
2answers
243 views

write a key command for a markdown comment

I've been messing about with file type specific commands this evening (which is going to be very useful) and I'm trying to write a markdown comment command at the moment. I'm not sure how to go about ...
5
votes
1answer
2k views

How does Vim know how to syntax-highlight some files with strange extension or without extension at all?

Take markdown file as an example. I often found that some downloaded files suffixed with .md (rather than .markdown) can be recognized as markdown file, and syntax-highlighted as such. However, it ...
1
vote
0answers
165 views

Disable tar.vim plugin from command line? [duplicate]

The tar.vim plugin tries to give a special view of tar files. Its filetype "detection" matches against the filename. If I try to download a tar file from the web and get an HTML error page, I cannot ...
16
votes
2answers
5k views

How to tell vim not to try to unzip a file

I'm trying to open an .xlsx file in Vim, but got an error saying: ***error*** (zip#Browse) unzip not available on your system I know it's a binary file, but I want to do some checksums and ...
8
votes
1answer
482 views

Run shell commands on current file based on file extension

I'm currently doing a lot of work with both Ruby and JavaScript. I know that I can run my Ruby files with :! ruby % and likewise my JavaScript with :! node %, and that I can bind either of those to, ...
94
votes
5answers
95k views

How to edit binary files with Vim?

Is there a way to edit binary files in some kind of hexadecimal mode? For example if I have some binary data shown by xxd or hexdump -C like this: $ hexdump -C a.bin | head -n 5 00000000 cf fa ed ...
20
votes
2answers
2k views

Open .md files as Markdown

Vim, by default, opens all .md files as "modula2" code. I have never heard of modula2, nor do I plan to use it. How can I tell vim to always treat foo.md as Markdown (as if I had typed :set ft=...
8
votes
2answers
266 views

How can I get correct autocompletion for ambiguous file extensions?

I'm editing Prolog files as part of an exploratory project, and some of the files I'm working with have the extension .pl, which is shared by Perl files. Whenever I do work on a Prolog file named [...
6
votes
2answers
136 views

Setting up ++ft according to the file extension

I have a lot of *.sage that follow the Python syntax. However, VIm does not recognize this. Can I make VIm set ++filetype based solely on the file extension?
41
votes
4answers
12k views

How can I change the default indentation based on filetype?

I'd like to have different indentations based on the type of file I am working on. For example, working on a .c file I'd like my indentation be 4 spaces. In .html files I'd like to (have to) work with ...

1 2 3
4