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
4
votes
1answer
115 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
2answers
30 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 ...
0
votes
0answers
31 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 ...
0
votes
0answers
26 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 ...
2
votes
1answer
33 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 ...
2
votes
2answers
37 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 ...
0
votes
1answer
30 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
vote
1answer
39 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=...
1
vote
2answers
71 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 ...
1
vote
2answers
28 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/...
2
votes
1answer
25 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 ...
2
votes
1answer
32 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. ...
2
votes
1answer
57 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,...
0
votes
1answer
39 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 ...
0
votes
1answer
32 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 ...
1
vote
1answer
91 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!...
2
votes
0answers
41 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 ...
2
votes
2answers
63 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 ...
4
votes
1answer
53 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 ...
3
votes
0answers
154 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 ...
1
vote
1answer
79 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>...
1
vote
1answer
16 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 ...
0
votes
1answer
44 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 ...
0
votes
0answers
27 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 ...
1
vote
2answers
27 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'...
3
votes
1answer
77 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 ...
1
vote
1answer
41 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 ...
2
votes
0answers
15 views

What pattern could I use to set a filetype for files ending in '.ot.txt' [duplicate]

I'd like to use VimOutliner with files ending in .ol.txt. This entry in ~/.vim/ftdetect/votl.vim doesn't do that au! BufRead,BufNewFile *.ol.txt setfiletype votl Is there a [pattern] for this?
1
vote
1answer
80 views

Changing filetype for *.mm files to cpp

I am try to change the filetype for *.mm files. I have created a mm.vim file in ~/.vim/ftdetect, with the following code: au BufNewFile,BufRead *.mm set filetype=cpp But the when opening a file with ...
1
vote
2answers
45 views

common /after/syntax for different file types

I want some common syntax highlighting for various filetypes. Currently I have runtimepath/after/syntax/base.vim which has syntax rules I want and then I created mklink (this is windows) to base.vim ...
3
votes
1answer
149 views

How to exclude filetype with autocmd to load language specific skeleton

I have the following in order to use a different template per language. But I want English to be the default, if I don't specify .en.adoc in the filename. But the *.adoc,*.en.adoc also picks up *.fr....
1
vote
0answers
61 views

Extending filetype functionality? [closed]

I'm trying to add some functionality by adding ftplugin files. For instance I want to add nnoremap <buffer> <F5> :source %<CR> to ftplugin/vim.vim, but when I try it, it looks like ...
1
vote
1answer
291 views

Syntax highlighting for fish script not working

I have both Vim version 8.1.1550 and NVIM v0.4.3 on MacOS 10.14.6 I wrote the following lines in my .vimrc file as recommended enter link description here set nocompatible filetype off set rtp+=~/....
1
vote
1answer
225 views

Changing foldmarker per filetype with vim 8.2

On an up-to-date Arch system, I set up marker-based folds in vim and python scripts like so: Extracted from my ~/.vimrc [1] set nocompatible " default filetype plugin indent on set nofoldenable set ...
2
votes
2answers
228 views

How do I elegantly override file type detection patterns with more specific patterns

I have a file in my ~/.vim/ftdetect directory, which includes configuration such as: autocmd BufRead,BufNewFile,BufWritePost .envrc.template set filetype=sh However, I also have the vim-polyglot ...
2
votes
1answer
175 views

How can I write a filetype plugin that evaluates the first lines of the file?

I'm trying to modify my filetype.vim such that it highlights a unified diff file with diff syntax, overriding whatever syntax is normally associated with the file's extension. So far, I'm just trying ...
0
votes
1answer
60 views

Is there a nice way to programmatically call the file auto-detection algorithm?

I was writing a simple Vim plug-in for a generic code generator called Templaty. The generator can theoretically work with any programming language, and I'd like Vim to automatically apply the correct ...
1
vote
2answers
406 views

Initial vim startup with small vimrc gives error “No such group or event: filetypedetect”

Using Vim 7.4. My ~/.vimrc file consists only of the following: set nocompatible filetype off If I run vim with verbose logging level 2 by using the following command: vim -V2./file.log .vimrc ......
2
votes
2answers
172 views

Solidity (*.sol) filetype not recognised in neovim

NeoVim is not recognising Solidity filetypes (which end with the extension .sol). When editing a .sol file typing: :set filetype? generates a filetype= (e.g. blank). This is in contrast to html, ...
2
votes
0answers
378 views

How to fix this `Omni completion (^O^N^P) Pattern not found` error?

I am trying to set up syntax keyword based omnicompletion in vim. I have defined a few syntax keyword Constants in ~/.config/nvim/syntax/spl.vim They are correctly detected and highlighted. They are ...
1
vote
1answer
92 views

Vim different colorchemes for different file, but same backgroung color

I'd like to have a colorscheme but keeping my terminal color as a background color. This code achieved that colorscheme MyFavoriteOne autocmd ColorScheme * highlight Normal ctermbg=NONE guibg=NONE I'...
1
vote
1answer
248 views

Is it possible to have vim run a command every time save `:w` is invoked?

I am editting typescript now, and I'd like to be able to have it so, whenever :w is invoked, the shell runs tsc compiling my new save. This beats having to !tsc every time. Does something like this ...
6
votes
2answers
1k views

Multiple vimrc files for different file types in vim?

I'm a vim beginner. I want to handle multiple programming languages. I find great resources for how to perfect vim for one programming language by putting ton of stuff in one vimrc file. This is ...
1
vote
1answer
146 views

How to disable intelligent indent for text/markdown files?

Since ever in my configuration of vim text and markdown-files are indented on following lines to align with open parenthesis. Text Text Text (e.g. Hello World) More Text This happens ...
1
vote
1answer
34 views

What does “one file for each filtype” mean in :h new-filetype

From :h new-filetype : A. If you want to overrule all default file type checks. This works by writing one file for each filetype. The disadvantage is that means there can be many files. The ...
1
vote
1answer
386 views

Why set ft is not working?

I have au BufRead,BufNewFile *.vm set ft=velocity in vimrc. But if open .vm file and run :set filetype?, still get filetype=conf. How to fix this?
1
vote
2answers
182 views

Linking a filetype to a syntax file of a different name

I’ve created a new filetype, “usenet,” for Usenet messages. I would like files with this filetype to be highlighted exactly as if they had the “mail” filetype. Is it possible to tell Vim that I want ...
1
vote
0answers
31 views

How to load a template file if new file is starting? [duplicate]

I'm a hobbyist go programmer, and I'm using vim-go to make vim efficient go editor. One thing I like about vim-go is, whenever in a directory, when you open a new .go file. It adds this: package ...
0
votes
1answer
38 views

Vim Jedi Plugin — Add .sage filetype

,g$$$$$$$$$$$$$$$P. OS: Debian 9.9 stretch ,g$$P"" """Y$$.". Kernel: x86_64 Linux 4.19.0-0.bpo.4-amd64 ,$$P' `$$$. Uptime: 3h 17m ',$$P ,ggs. `$$...
1
vote
1answer
126 views

Multi-line array variable in bash with filetype sh does not indent correctly

I have the following bash array after automatic indentation, both on pressing carriage return when was editing in :h Insert mode and doing =ip on the block in :h Normal-mode DOTFILES=( ".bashrc" "....