Skip to main content

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
2 votes
1 answer
134 views

Better to edit $VIMRUNTIME/filetype.vim or add a script in $HOME/vimfiles/ftdetect?

Dead simple question: is it best practice to: edit $VIMRUNTIME/filetype.vim itself, or add a script in $HOME/vimfiles/ftdetect?
okto's user avatar
  • 23
0 votes
1 answer
36 views

How to hide keybinds in which-key.nvim depending on buffer type?

I have been refactoring my nvim setup. I manage my plugins with lazy.nvim. I have vimtex plugin, with following binds: local wk = require"which-key" wk.register({ l = { name = &...
Vladyslav Rehan's user avatar
1 vote
1 answer
68 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), ...
sampi's user avatar
  • 133
2 votes
3 answers
47 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 ...
Matthias's user avatar
2 votes
1 answer
44 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 ~?
javilan's user avatar
  • 23
0 votes
1 answer
30 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 ...
bcag2's user avatar
  • 101
1 vote
1 answer
38 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 ...
Konstantin Glukhov's user avatar
0 votes
1 answer
255 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 ...
user50451's user avatar
4 votes
1 answer
227 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 ...
mEm's user avatar
  • 157
2 votes
2 answers
291 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 ...
moo's user avatar
  • 155
1 vote
1 answer
69 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() :...
balki's user avatar
  • 365
1 vote
1 answer
163 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\+$...
Attilio's user avatar
  • 369
2 votes
3 answers
522 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 ...
ngn's user avatar
  • 163
2 votes
1 answer
59 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 ...
aky-her's user avatar
  • 143
1 vote
1 answer
115 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 ...
Jim Fischer's user avatar
0 votes
1 answer
147 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 ...
maxemilian's user avatar
0 votes
2 answers
376 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 ...
StoneThrow's user avatar
1 vote
2 answers
218 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 ...
Barzi2001's user avatar
  • 640
1 vote
1 answer
68 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 ...
videbar's user avatar
  • 13
0 votes
2 answers
249 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 ...
NeoZoom.lua's user avatar
  • 1,530
0 votes
1 answer
842 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 :...
NeoZoom.lua's user avatar
  • 1,530
0 votes
1 answer
43 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 --...
Enlico's user avatar
  • 2,244
1 vote
2 answers
160 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 ...
Alex Roberts's user avatar
0 votes
1 answer
449 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 ...
mpounsett's user avatar
  • 101
-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 #####. ...
newview's user avatar
  • 301
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 = ...
RubenLaguna's user avatar
1 vote
2 answers
56 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 ...
Andy A.'s user avatar
  • 233
0 votes
3 answers
69 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'...
newview's user avatar
  • 301
1 vote
0 answers
54 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 ...
markling's user avatar
  • 389
0 votes
0 answers
138 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[...
Sam's user avatar
  • 101
0 votes
0 answers
61 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 ...
hermancain's user avatar
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;} ...
kongou's user avatar
  • 1
0 votes
1 answer
359 views

How to disable spell check for certain file types

How can I disable spell check for files likes yaml, json?
Renato Prado's user avatar
0 votes
1 answer
141 views

vim status bar not consistent in all file

I recently set my vim status bar using this: " set status line set laststatus=2 set statusline= set statusline+=%#StatusLineFile# set statusline+=\ %F set statusline+=%m set statusline+=%= set ...
Yuanhao JIANG's user avatar
1 vote
1 answer
173 views

Is there a way to detect all the autocommand that have been triggered?

I have a file for which the filetype is not correctly set. The filetype is set by an autocmd but I would like to identify which one. How can I know which autocmd have been triggered when I load my ...
Vivian De Smedt's user avatar
-1 votes
1 answer
118 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 ...
Nikola-Milovic's user avatar
1 vote
1 answer
34 views

To not treat files like 'vimrc-tips.txt' as Vim Script files

There is a line in defaults.vim that enables Vim Script syntax for any .txt file with vimrc in its filename (for example, vimrc-tips.txt): au BufNewFile,BufRead *vimrc* call s:StarSetf('vim')...
user90726's user avatar
  • 123
0 votes
2 answers
198 views

What is wrong with my autocommand groups?

This is the current state of my autocmds.vim file. " Option for specific filetypes autocmd BufRead,BufNewFile *.md setlocal textwidth=...
paradroid's user avatar
  • 377
2 votes
1 answer
546 views

How can I enable .xml syntax highlighting for .xaml files?

I am trying to enable .xml syntax highlighting in Vim for .xaml files since .xaml files don't have syntax highlighting of its own. I came across a post on Stack Overflow which recommended to use au ...
Jose Membreno's user avatar
1 vote
0 answers
384 views

How to map keybindings only for specific file type?

In vimwiki, <C-x><C-o> provides available tags in autocomplete dropdown. I am attempting to map that key mapping to something easier like (ctrl+alt+space) and only when I am in a markdown ...
haku's user avatar
  • 111
6 votes
0 answers
2k views

Can (Neo)Vim be configured to set the filetype according to the shebang?

Lately I've been using neovim to edit lots of files with the .tmpl extension. These files all have shebangs, most (but not all) of which are #!/bin/sh. The default behavior seems to be that neovim ...
Brian Fitzpatrick's user avatar
4 votes
2 answers
8k views

How do I port a filetype command to neovim's lua format?

Currently my .vimrc file has this in it, filetype plugin indent on -- filetype detection[ON] plugin[ON] indent[ON] How can I port filetype plugin indent on to neovim's lua format?
Evan Carroll's user avatar
  • 1,433
1 vote
1 answer
158 views

How to share snippet between typescript and typescriptreact?

I use UltiSnips to manage my snippets and I have a few snippets in typescriptreact but I'm not able to use them in typescript. Is there a way to share snippets between them?
Lai32290's user avatar
  • 275
0 votes
0 answers
13 views

Source script on a specific filetype without .vimrc modification [duplicate]

Is there a mechanism that I can use in vim/gvim which lets me automatically source a specific script file when I open a file of certain type? I have a specific file format (a subtype of XML) and when ...
performancematters's user avatar
1 vote
1 answer
79 views

How can I change the way filetype is set from the "#lang" directive in Racket

I have some Racket programms that begin with the specification of a dialect #lang plai-typed #| racket code goes here ... |# When I open these files with Vim, filetype is set to plai-typed. That is ...
user avatar
2 votes
1 answer
136 views

filetype is empty when editing a file

I want to source file csv.vim when editing a csv file. But when I editing a .csv file , it is not sourced and set filetype? returns filetype=
di bao's user avatar
  • 21
0 votes
1 answer
179 views

Why runtime! is not working?

Add customise filetype setting file do.vim inside ftdetect folder. Edit gvim/8.2/share/vim/vim82/filetype.vim: runtime! $HOME/.vim/ftdetect/*.vim Open file, run verbose set ft?. From print, filetype ...
Fisher's user avatar
  • 1,086
0 votes
0 answers
40 views

When I open a .txt file, the double quotes ( " )are suppressed

First, I tried on Linux: I opened a .txt file (or copy and past the text from a website) but the double quotes are not shown... On Linux, they are replaced by this: ~~@~~ On Windows 10 (I use gVim on ...
alexandre's user avatar
1 vote
0 answers
93 views

What could interfere with setting foldmethod=indent by autocmd FileType python?

So recently I noticed my autocmd FileType python setlocal foldmethod=indent is not working anymore. The version for my vim is 8.2 When I open a python file everything is working fine except the ...
cccplex's user avatar
  • 111
0 votes
0 answers
441 views

Setting ftdetect a given directory

I'm looking for a way to set filetype on load, a loading phase via ftdetect. Right now I can open the files inside a given directory via some utility function that I wrote, and during the opening ...
ekiim's user avatar
  • 133

1
2 3 4 5