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
1answer
9 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
30 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
36 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
33 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
26 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
78 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
35 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
47 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 ...
3
votes
1answer
36 views

How to get syntactic coloration for dist files

There is a standard for providing files that may have unversioned counterpart. That standard consists in suffixing the filename with .dist, so for example phpunit.xml becomes phpunit.xml.dist. How can ...
3
votes
0answers
88 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
50 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
12 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
41 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
23 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
26 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
70 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
26 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
50 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
44 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
121 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
51 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
170 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
106 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
143 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
158 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
54 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
285 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
127 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
287 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
58 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
182 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
100 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
311 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
156 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
36 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
96 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" "....
0
votes
0answers
17 views

How can I reproduce a Linting Plugin Behavior

I'm trying to get in to plugin writing, and currently I'm doing some builds (like Latex and LanguageTools checker), and I have in place hotkeys that call for the compilation, and It throws the output ...
0
votes
1answer
220 views

autocmd for markdown textwidth=100 failing

I want to set my markdown files to have textwidth=100 but cannot get it working. The strange thing is that it works sometimes and sometimes not. My autocmd is: augroup auFileTypes autocmd! ...
1
vote
1answer
336 views

Vim not setting correct file type for jinja files

Whenever I create html file with jinja code from terminal either using shell commands or directly using vim, the file type is always set to html and not jinja.html, which causes number of issues like ...
0
votes
1answer
109 views

fake a filename for filetype detection when reading from stdin

When reading from stdin with something like fancy-command | vim -R -, vim does not detect the filetype (i.e. set filetype prints filetype=). When I know the right vim filetype, I can provide it from ...
0
votes
1answer
105 views

execute 'Goyo' on loading pandoc document

It seems like running the Goyo command (a distraction free editing plugin) on loading a pandoc document should be really simple, but execute "Goyo" in .config/nvim/ftplugin/pandoc.vim leads the ...
2
votes
1answer
82 views

Share configuration across `ftplugin` files without duplicating code

A lot of languages use curly braces {} to enclose code blocks, so it's nice to have a mapping something like: inoremap <buffer> {<CR> {<CR>}<Esc>O I have this mapping in ...
0
votes
0answers
36 views

Automatically uncompress section of buffer

I'm using a simple text file in Vim as a task manager and am keeping completed tasks in an archive section of the same file. I'd like to compress that section of the buffer when saving changes to a ...
5
votes
1answer
546 views

How to debug “Unknown function: dist#ft#SetFileTypeSH” after upgrade to 8.1

edit: Solution found! At the bottom of the post I installed vim 8.1 via brew on macos Sierra yesterday, and I think that broke some of the filetype setting stuff. When I open a shell script, I get ...
0
votes
2answers
113 views

Help for filetype specifics

I often find myself jotting notes in Vim using an empty buffer which in this case has 'no ft' (status line). I know I could set the filetype with :setfiletype text but I honestly wonder what that ...
1
vote
0answers
55 views

Airline section_x for particular filetype

For .js files, I set a particular filetype in order to enable snippets, like this: augroup project autocmd! autocmd BufRead,BufNewFile *.js set filetype=javascript.javascript-es6-react.jsx ...