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
23 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 --...
  • 1,984
1 vote
2 answers
65 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 ...
0 votes
1 answer
29 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 ...
  • 101
0 votes
1 answer
35 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 #####. ...
  • 163
1 vote
0 answers
185 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 vote
2 answers
41 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 ...
  • 201
0 votes
3 answers
43 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'...
  • 163
1 vote
0 answers
24 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 ...
  • 309
0 votes
0 answers
50 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[...
  • 101
0 votes
0 answers
20 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
34 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;} ...
  • 1
0 votes
1 answer
30 views

How to disable spell check for certain file types

How can I disable spell check for files likes yaml, json?
0 votes
1 answer
59 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 ...
1 vote
1 answer
24 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 ...
-1 votes
1 answer
43 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 ...
1 vote
1 answer
28 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')...
0 votes
2 answers
60 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=...
  • 228
2 votes
1 answer
142 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 ...
1 vote
0 answers
73 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 ...
  • 111
4 votes
0 answers
610 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 ...
0 votes
2 answers
2k 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?
1 vote
1 answer
84 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?
  • 205
0 votes
0 answers
12 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 ...
1 vote
1 answer
45 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 ...
2 votes
1 answer
88 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=
  • 21
0 votes
1 answer
88 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 ...
  • 1,002
0 votes
0 answers
37 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 ...
1 vote
0 answers
61 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 ...
  • 111
0 votes
0 answers
217 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 ...
  • 121
0 votes
0 answers
38 views

Formatting with gg=G on *.cfg files (Nagios) results in bad indentation

Search-fu power is eluding me for this one. Have many Nagios (*.cfg) files under audit, using Vim to work on them. Notice that doing gg=G is not correctly formatting the files or a block if using = ...
  • 101
9 votes
1 answer
737 views

How to do file type detection based on file contents (e.g. a certain shebang line)?

I have created a few scripts in .vim/ftdetct to e.g. detect the filetype of sshconfig files based on their filename: autocmd BufRead,BufNewFile ~/.ssh/host-* setfiletype sshconfig Now, how can I make ...
  • 1,145
0 votes
1 answer
365 views

Should the filetypedetect augroup be used in plugins?

I'm writing my first Vim/Neovim plugin, which improves support for files managed by yadm. Pretty straightforward. However, while reading other plugins for inspiration, I have noticed that plugin ...
0 votes
0 answers
91 views

Should an exclamation point be added after an "autocmd" in a filetypedetect augroup?

I'm trying to learn more about augroups, which have always confused me. The Section 43.2 documentation (:help 43.2) makes it clear that the filetypedetect group should be used to group autocmds which ...
0 votes
1 answer
50 views

Assign value based on filetype [duplicate]

I want to assign value based on filetype. I am using UltiSnips plugin and want to have one set of bindings for one filetype and another set for everything else. Something like if &ft='vimwiki' ...
1 vote
2 answers
173 views

How to substitute filename on reading or opening new file

We have rather complex file structure and I would like simplify opening file independently where am I in the filesystem at the moment. Let's say we have a project_folder and several files in it: /...
  • 123
0 votes
0 answers
109 views

How to apply existing indenting rules to new file type?

I've been happily using vim for years for C and C++ projects. My code formatting/indentation rules have been cobbled together over the years based on solutions to at-the-time needs...which is to say, ...
1 vote
2 answers
87 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 ...
  • 243
0 votes
2 answers
576 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 ...
0 votes
1 answer
56 views

How to ignore or push back certain files when when auto-completing in wildmenu?

When opening a file with :e, :vs or :sp, I generally don't want to open binary files or files with certain extensions like .class. Is there a way to ignore files with certain extensions or MIME type (...
0 votes
0 answers
188 views

Let .js files be recognized as .jsx files?

I just figured out how to combine those creepy plugins to work together to achieve the following auto-indent: before / after pressing o: But then this only works on file extension .jsx as shown above,...
  • 1,055
0 votes
1 answer
136 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 ...
1 vote
4 answers
469 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 ...
  • 166
0 votes
1 answer
1k views

"command not found" error using filetype plugin [closed]

I am trying to add filetype plugin indent on to my vimrc, and I'm getting the error filetype: command not found. I tried searching but can't find a solution. I have the full vim package installed (not ...
  • 103
4 votes
1 answer
152 views

What is the most idiomatic way to achieve filetype-specific functions?

Is it possible to declare a function only for a specific filetype? Currently, if I have the following in ftplugin/tex.vim: function! Foo() echom "yes" endfunction Then when I load a *....
0 votes
2 answers
100 views

Automatically resize window based on filetype

I have a nifty autocommand in my vimrc that automatically maximizes any :help window: augroup LargeHelpWindow autocmd! autocmd BufWinEnter * if &l:buftype ==# 'help' | wincmd _ | endif ...
  • 275
0 votes
0 answers
140 views

Filetype inheritance

I know that it's not very common, but there are few cases in which I would really like to inherit the configurations for one filetype in another. Example: whatever I set for sh I would like to inherit ...
  • 101
0 votes
0 answers
203 views

syntax highlight regex not matching

I am writing a plugin where a certain filetype must possess their own syntax highlight. Therefore I have created . ├── ... ├── plugin └── syntax and syntax/newfiletype.vim containing syntax clear ...
  • 109
4 votes
1 answer
192 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 ...
  • 1,145
2 votes
2 answers
281 views

How to re-indent nginx configuration based only on `{` and `}`?

I want to reindent an nginx configuration file with the following simple rudimentary rules: a { increases indentation a } decreases indentation The idea is cindent is just enough to do it. I have ...
  • 183
0 votes
1 answer
281 views

Make function run only on specific filetype

So i have a specific function I'd like to edit in my .vimrc, so that it work only on specific filetype (eg: .vim). The code for this example is taken from this answer. function OrgFold(lnum) let ...

1
2 3 4 5