Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take 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
2 answers
171 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?
user avatar
1 vote
1 answer
29 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?
user avatar
  • 163
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 ...
user avatar
1 vote
1 answer
28 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
50 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=
user avatar
  • 21
0 votes
1 answer
41 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 ...
user avatar
  • 900
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 ...
user avatar
1 vote
0 answers
44 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 ...
user avatar
  • 111
0 votes
0 answers
103 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 ...
user avatar
  • 121
0 votes
0 answers
31 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 = ...
user avatar
  • 101
5 votes
1 answer
336 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 ...
user avatar
  • 995
0 votes
1 answer
158 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 ...
user avatar
0 votes
0 answers
63 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 ...
user avatar
0 votes
1 answer
40 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' ...
user avatar
1 vote
2 answers
109 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: /...
user avatar
  • 123
0 votes
0 answers
73 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, ...
user avatar
1 vote
2 answers
64 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 ...
user avatar
  • 223
0 votes
2 answers
323 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 ...
user avatar
0 votes
1 answer
27 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 (...
user avatar
0 votes
0 answers
128 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,...
user avatar
  • 731
0 votes
1 answer
101 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 ...
user avatar
1 vote
3 answers
257 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 ...
user avatar
0 votes
1 answer
622 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 ...
user avatar
  • 103
4 votes
1 answer
146 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 *....
user avatar
0 votes
2 answers
62 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 ...
user avatar
  • 255
0 votes
0 answers
90 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 ...
user avatar
  • 101
0 votes
0 answers
127 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 ...
user avatar
  • 109
3 votes
1 answer
130 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 ...
user avatar
  • 995
2 votes
2 answers
182 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 ...
user avatar
  • 173
0 votes
1 answer
86 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 ...
user avatar
1 vote
1 answer
98 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=...
user avatar
  • 388
1 vote
2 answers
85 views

How to configure settings common to many programming languages?

I edit a lot of different file types, like .c, .cc, .S, .py, .rs, .ld, plus maybe a dozen more. And I'm constantly editing new file types, so I'm adding to this list. I have settings I want to apply ...
user avatar
  • 177
1 vote
2 answers
141 views

Where should I put filetype specific options for indentation?

At moment, mostly for random reasons, I have $ cat ~/.vim/ftplugin/c.vim set tabstop=2 softtabstop=2 expandtab shiftwidth=2 smarttab smartindent autoindent cinoptions=g2 and this $ cat ~/.vim/...
user avatar
  • 1,572
2 votes
1 answer
125 views

Is there a filetype in Vim when opening the a file containing output/errors from g++ so that I can see those files with the original coloring?

Sometimes, when faulty outputs from compilations of C++ files/projects are to long, I like to redirect that output to a file, so that I can inspect it side-by-side with each of the offending files in ...
user avatar
  • 1,572
2 votes
1 answer
37 views

Position Dependent Custom Syntax Error Checking

I am trying to design a custom syntax file that performs some basic error checking for an ascii input file. The input is broken up into sections, and there are input cards specific to each section. ...
user avatar
  • 328
2 votes
1 answer
208 views

Why are nested FileType autocommands triggered even ++nested is not used?

From :h autocmd-nested, it says "By default, autocommands do not nest." But nested FileType events are triggered anyway without using ++nested. As seen in this test: autocmd BufNewFile,...
user avatar
0 votes
1 answer
84 views

filetype plugin indent on is blowing up my vim

I have the following vimrc. I noticed that there is a single line that's blowing up my usage of the FZF :BTags command: filetype plugin indent on Ie when I run the command :BTags I get this error ...
user avatar
  • 539
0 votes
1 answer
90 views

Unwanted cascading indentation [duplicate]

I am struggling to regain control of indentation for certain filetypes, particularly when pasting code. I end up with what I call "cascading indentation" which is nearly unreadable. I've run ...
user avatar
1 vote
1 answer
191 views

How can I make vim ignore a filetype plugin's makeprg setting?

I am using a plugin that sets makeprg to some value specific to the filetype's programming language. I want to use my global setting instead, because I also use Makefiles. How can I do this? Thank you!...
user avatar
2 votes
0 answers
129 views

Minimum window width will not change when using specific filetype

With most filetypes, I can resize font and my GVIM application window just fine. However, when I open a specific file type (.tex), the font is easily changed, but I am unable to shrink the application ...
user avatar
  • 187
2 votes
2 answers
126 views

Where do filetype-specific autocommands live?

I have a plugin for a specific filetype (*.tex), and I'm wondering where I can find all the commands which are executed when I type :e examplefile.tex? In general, is there a standardized practice for ...
user avatar
  • 187
4 votes
1 answer
59 views

How to get syntactic coloration for dist files

There is a standard for providing files that may have an unversioned counterpart. That standard consists in suffixing the filename with .dist, so for example phpunit.xml becomes phpunit.xml.dist. How ...
user avatar
  • 143
3 votes
0 answers
546 views

"^[[201~" character being pasted at the end of file

I'm trying to copy-paste by hand this file, but whenever I paste the contents in vim the last line shows this weird character at the end of the line ^[[201~. My guess is that it's one of those wrong ...
user avatar
  • 133
1 vote
1 answer
209 views

autocmd filetype nnoremap is not working

I'm trying to create a mapping based on the file type. (as explained in this chapter https://learnvimscriptthehardway.stevelosh.com/chapters/12.htm) :autocmd FileType javascript nnoremap <buffer>...
user avatar
  • 191
1 vote
1 answer
32 views

How to "cast" filetype (HTML/JS/PHP) on temporary buffer to load plugins & configurations

I'm using neovim with vim-plug. I do some webapp testing where I want to see the raw HTML/JS/PHP/etc of a page. This can be done with something like curl example.com > tmp.html; nvim tmp.html and ...
user avatar
0 votes
1 answer
58 views

Adding Filetype != filetypes

I have the following mapping: augroup MatchingQuotes autocmd Filetype noremap! ' ''<Left> autocmd Filetype noremap! " ""<Left> augroup END Is there a way to set ...
user avatar
  • 1,767
0 votes
0 answers
28 views

When does filetype run?

I have the following autocmd: :autocmd FileType python syntax off Yet when I open a python file it does nothing. I literally have to run :set ft=python for this to trigger. Does the FileType python ...
user avatar
  • 1,767
1 vote
2 answers
56 views

Assign a filetype when editing any file from a directory

The context I store all my shell scripts insde the $HOME/.bin directory. Because of this, I've been looking for a way to set the sh filetype whenever I open a file located in that directory. So, I'...
user avatar
  • 225
3 votes
1 answer
109 views

Disabling `kana/vim-textobj-entire` by filetype autocommand

kana/vim-textobj-entire creates text-obejcts ae and ie which stand for the entire buffer. But in lervag/vimtex ae and ie stand for an environment in a .tex file. vimtex's ae and ie mappings are much ...
user avatar
2 votes
1 answer
132 views

Why do FileType autocommands not appear to work when using multiple filetypes?

Not everyone considers setting b:undo_ftplugin to be a "best practice" the way I do, but as far as I can tell, the behavior described in this question depends on it being set as part of the ...
user avatar
  • 20.7k