Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
0 votes
1 answer
237 views

folding.vim file, for a specific filetype, is being ignored

I want to write a custom fold-method file for .paul files (based on the example at Learn Vimscript the Hard Way). However, it appears that my folding.vim file is being ignored. I'm running VIM version ...
0 votes
1 answer
21 views

set syntax color to log files, .env.local files without detected extension

sometimes, vim don't color text because file haven't got extension or the right extension, like /var/log/syslog.1, or .env.local How to define color syntax temporarily or definitely ? How to know ...
3 votes
0 answers
687 views

in-line math equation rendering/preview for macvim/vim for filetypes other than RMarkdown

I recently installed vim-rmarkdown package, and found that the package allows me to see the rendered math equation in macvim, and when move cursor over, the line will render back to latex equation ...
1 vote
1 answer
66 views

The most appropriate filetype for fail2ban configuration files?

When opening any file fail2ban configuration file, it typically gets detected as having the conf filetype due those files .conf filename suffix. The fileformat is explained in detail in jail.conf(5), ...
2 votes
3 answers
36 views

Setting variables in file in ftplugin directory

I am currently cleaning up my .vimrc. I learned that I can spread out filetype specific commands into separate files in the .vim/vimfiles directory by putting them into ftplugin and after/ftplugin ...
2 votes
1 answer
26 views

How do I prevent/remove/delete temp files?

When I create .txt files using Vim the following files are also created. How do I prevent/remove/auto-delete the files ending in ~?
0 votes
1 answer
122 views

Conditional Key Mapping in Neovim Based on File Type

How can I do in nvim if the file type is js do this: vim.api.nvim_set_keymap('n', '<A-1>', [[:w | split term://node % <CR>]], { noremap = true, silent = true}) else if file type is lua do ...
1 vote
2 answers
151 views

Editing .bib files in (n)vim with tailored autocompletion

I use BibDesk on a Mac to edit .bib files (in biblatex, using biber to compile). This generally works, but for various reasons it would be nice to be able to edit them in nvim too. My current setup ...
1 vote
1 answer
28 views

Is there a way to override filetype syntax?

I have a file.conf that has jsonc data. I tried the following hints at the beginning of the file: // vim: ft=jsonc and # vim: ft=jsonc but it has no effect, the filetype is still set to conf. I know ...
4 votes
1 answer
361 views

How to set the background color for colored items in the statusline to the background color of the statusline?

I am experimenting with creating a statusline and have opted for coloring different parts of it. The problem is that while the item's foreground color is changed, the background is black and doensn't ...
7 votes
1 answer
4k views

In what order does vim read ftplugin files, syntax files, and the .vimrc when `filetype plugin on` and `set syntax=filetype` are called?

I've had some issues reconciling my .vimrc with files in ftplugin and after/ftplugin. In what order are they all read? For example: When vim encounters the line plugin filetype on in a .vimrc file, is ...
4 votes
1 answer
220 views

How is filetype tex and plaintex set in vanilla Vim?

I noticed that when I create a .tex from within Vim itself, in a later session that file is detected as plaintex, while already existing files are detected with the tex filetype (note: both of them ...
116 votes
8 answers
142k 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 ...
1 vote
2 answers
206 views

How to automatically close all the terminal buffers when closing vim with :qa?

I am wondering if there is a way to automatically force-wipe all the running terminals when quitting Vim with :qa. My attempt (that does not work): vim9script def WipeoutTerminals() for buf_nr in ...
2 votes
2 answers
210 views

Additional filetypes for different types of yaml files

Is it possible to create additional subcategories of filetypes? For example, it would be great if (neo)vim could pick up that the yaml file I'm editing is acutally a Kubernetes yaml file and set the ...
1 vote
1 answer
64 views

Autocommand is executed multiple times on filetype

I am trying to auto format python files on save. first.py #!/usr/bin/python3 print( "first") second.py #!/usr/bin/python3 print( "second") py.vim def BlackFormat() :...
1 vote
1 answer
136 views

What is the difference between `au BufNewFile,BufRead *.py` and `au Filetype python` in this specific case?

The issue Consider the following two Vimrc configuration lines for the YouCompleteMe plugin: au BufRead, BufNewFile *.py,*.pyw match BadWhitespace /\s\+$/ au FileType python match BadWhitespace /\s\+$...
2 votes
3 answers
933 views

How to set autocmd for files without a filetype?

I want some autocmds to run when I open a file without a filetype like nvim (no file name) or nvim myfile (no extension). I also want them to run when opening certain file types like text and markdown ...
2 votes
3 answers
503 views

How can I avoid built-in filetype detection?

I have a plugin for detecting and syntax highlighting *.k - source files in a given programming language. My ~/.vimrc contains only: se nocp rtp+=~/k/vim-k " the language plugin sy on And ...
2 votes
1 answer
57 views

Vim behaves differently when editting a file named "Changelog.txt"

I created a (new and empty) file Changelog.txt and Vim started with completely different settings than with any other text file (yellow font, automatic line breaking, maybe more I didn't notice). As ...
1 vote
1 answer
104 views

List known abbreviations for filetypes

This VI StackExchange message thread provides useful tips for generating a list of known filetypes. However, I often see Vim modelines use abbreviations like js for javascript. These abbreviated ...
-1 votes
1 answer
51 views

How can make the expansion to take effect in any type of file?

If I add the following lines in html.snippets: snippet "(\S+)(\d+)" "Repeat token n times" r `!p snip.rv = int(match.group(2)) * match.group(1)` endsnippet #5 can expand to #####. ...
0 votes
1 answer
129 views

Is there any way to set ccze color scheme?

I want to use ccze color scheme for log file specific. augroup LogColorscheme autocmd! autocmd FileType log colorscheme ccze augroup END However, this installed color scheme on system-wide ...
0 votes
2 answers
333 views

ftdetect, ftplugin not working as advertised -- what am I missing?

I've been reading documentation and trying experiments to register a new filetype in vim, and apply desired indentation rules -- all to no avail. As an example, say I want to register *.test as ...
19 votes
3 answers
3k 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 ...
8 votes
2 answers
3k views

Mardown files always have vimwiki filetype (vimwiki plugin)

Here is the relevant content of my .vimrc let g:vimwiki_global_ext=0 let g:vimwiki_list = [{'path': 'C:\Users\<USER>\vimwiki', \ 'syntax': 'markdown', 'ext': '.md'}] The ...
1 vote
1 answer
62 views

What is changing the textwidth on rust files?

This seems like a bizarre behavior to me. I've set the textwidth to 88, but I've noticed that, when editing a .rs file, something sets it to 99. At first I though it must be some plugin or formatting ...
11 votes
3 answers
3k views

Setting syntax in ftplugin

I’m trying to set the syntax of Processing files (*.pde) to java with a ftplugin. .vim/ after/ ftdetect/ pde.vim ftplugin/ processing.vim In after/ftdetect/pde.vim I ...
6 votes
3 answers
2k views

Syntax highlight fail for Prolog files

I'm having trouble configuring Vim on Manjaro: After setting syntax on at .vimrc file, I make a Prolog program (bug.pl) which shows no syntax highlight: But after I append /**/ to top of file (then ...
0 votes
2 answers
205 views

How to set all files under a folder to a specified filetype?

I have some zsh function files that I should not add extensions to for the convenience of calling, i.e. my_func instead of my_func.zsh. But this causes an issue that Neovim cannot detect their ...
0 votes
1 answer
741 views

Do I need to set `:filetype on` myself in Neovim?

As title. I'm a user of Neovim and am trying to learn something very basic. My point is that I don't want to set things that will be enabled by Vim by default. And what's the relation between :...
3 votes
1 answer
4k views

Is it possible to set a vim.api.nvim_create_autocmd for a FileType (not just a pattern)?

Currently I'm using pattern in vim.api.nvim.create_autocmd(): vim.api.nvim_create_autocmd({ "BufEnter", "BufFilePost" }, { pattern = { "*.tf" }, callback = ...
-1 votes
1 answer
107 views

Specific filetype files should end with new line

my work project requires a newline at the end of a file. If I add a new line and save, it gets automatically removed. I work in Golang but the same behavior is observed in Lua, Rust and probably ...
0 votes
1 answer
40 views

Is it possible to delete part of a wildcard autocmd?

If I put this augroup AU_NAME autocmd! autocmd CursorMoved *.cpp,*.hs echo localtime() augroup END autocmd! AU_NAME CursorMoved *.cpp in my vimrc, then open a file and enter :au AU_NAME, I see --...
17 votes
4 answers
13k views

How can I make highlighting commands in .vimrc take effect immediately with Vim 7.4?

I have several highlight commands in my .vimrc file. In Vim 7.3, these took effect immediately after Vim had started. After updating to Vim 7.4, this is not the case anymore. Vim uses its default ...
1 vote
4 answers
713 views

How to Create Sublime-Like Build Systems in Vim?

I am currently new to neovim. Something that has me a bit stuck is being able to easily run my code. The text editor I used before trying out vim was Sublime Text 3, and, in that text editor, all I ...
2 votes
1 answer
487 views

Combine FileType with other events

I'd like to combine two events: FileType and TextChangedI. According to this awesome book I can do that, by adding a comma between both events like this: :autocmd BufWritePre,BufRead *.html :normal gg=...
3 votes
2 answers
1k views

How to tell vim to behave the same for file extension .in and .mako

I noticed Vim will choose the correct syntax when I open a file that ends with .c.in or .pl.in. I would like to tell Vim to behave the same with extensions like .c.mako or .pl.mako. How is it ...
0 votes
1 answer
398 views

`au BufWritePost` equivalent that matches on FileType?

There are a few cases where the file extension isn't necessarily indicative of the file contents, and filetype needs to be set with a modeline. For example, Salt *.sls files can contain many ...
1 vote
2 answers
55 views

Set mappings dependent of file type

To execute and debug different kind of programs, I mapped the function keys in the .vimrc-file. E.g. " save and execute perl :noremap <F5> :w<CR>:!./%<CR> " save and ...
0 votes
3 answers
68 views

Output all filetypes into a file

echo getcompletion('', 'filetype') The ex-command above lists all supported filetypes in vim. How can I output it into a file? I tried these two ways but none worked. echo getcompletion('', 'filetype'...
2 votes
1 answer
2k views

How can I prevent the default loading of ftplugin/text.vim for certain *.txt files?

I have to edit a bunch of *.txt files for which I want to define a specific filetype. So, in my vimrc, I add a autocmd! BufReadPost bunchOfFiles/*.txt :set ft=bunchOfFilesFT This reads ftplugin/...
11 votes
0 answers
1k views

Support for embedded languages

Vim supports syntax highlighting for embedded languages or fenced code in markdown (:h :syn-include). However, you usually want that other vim settings and mappings are adjusted for embedded languages ...
19 votes
2 answers
7k 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 probably ...
1 vote
0 answers
53 views

Stop foldmarker inserting hash

I my folds are set with foldmarker={{{,}}}. When I create a fold it inserts a comment # char before the marker. So it inserts #{{{. How do I stop it doing this? I have syntax highlighting (and it ...
0 votes
0 answers
132 views

Neovim recognizes LaTeX class files (.cls) as filetype=st

When I run nvim test.cls (a LaTeX class file looking something like this: \NeedsTeXFormat{LaTeX2e} \ProvidesClass{landscapetest}[forcing landscape mode] \LoadClass[landscape]{article} \RequirePackage[...
0 votes
0 answers
59 views

How can I enable html autocomplete in .tmpl files?

I'm editing .tmpl files which are mostly html with some template language syntax inside {{ double curly braces }}. I'm using COC for autocompletion and I want to be able to use the autocomplete ...
0 votes
0 answers
69 views

Vim automatically inserts "* " add the start of every new line in css files

If theres a "* " at the start of the previous line Vim automatically inserts a "* " at the start of the next new line. I want Vim to not insert anything. examples: 1|* {margin: 0;} ...
0 votes
1 answer
310 views

How to disable spell check for certain file types

How can I disable spell check for files likes yaml, json?
1 vote
2 answers
120 views

Open buffer without loading ftplugins

I have huge file and quite slow plugin (loaded by vim-plug) for corresponding filetype. I want following: Plugin is loaded by default Option to fast open this file without loading plugin. Something ...

1
2 3 4 5