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
0answers
31 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
24 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
35 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 ...
2
votes
0answers
60 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
36 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
10 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
39 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
57 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
25 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
37 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
42 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
110 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
44 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
96 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
75 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
109 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
152 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
207 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
108 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
239 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
53 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
155 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
888 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
72 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
275 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
143 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
33 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
87 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
204 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
318 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
102 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
101 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
80 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
494 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
103 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
51 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 ...
-1
votes
1answer
210 views

Automatic highlighting non ASCII character when loading 'vim' filetype buffer

I want to include a new highlight group and autocommand that will automatically highlight non-ASCIIs as soon as either a vimscript or a Python file is loaded in buffer (i.e. any file with filetype '...
3
votes
0answers
374 views

Support for embedded languages

Vim supports syntax highlighting for embedded languages, also called fenced code (:h :syn-include). However, you usually want that other vim settings and mappings are adjusted for embedded languages ...
3
votes
1answer
40 views

Ask if file extension is missing when opening new file

I use auto completion in my shell (zsh) and I'm often a bit sloppy. Scenario: Imagine I have the files sourcecode.c and sourcecode.h in the current directory. I type vim sour<TAB><ENTER> ...
3
votes
1answer
588 views

Using Pandoc with vim keybindings

I am trying to define a keymapping in vimrc to compile my markdown file with Pandoc. So I am using this: autocmd FileType markdown nmap <F9> :!pandoc % -o %:r.pdf <cr> But, in markdown ...
0
votes
1answer
156 views

how to set filetype after session restored with vim-session plugin

I used exvim as session manager, it uses a project file with extension .exvim. The session is auto-loaded when double click the .exvim, and auto-saved on exit. But there're bugs and the dev is ...
2
votes
0answers
465 views

Vim not recognizing markdown and tex files

Here is a sample of my .vimrc, that doesn't do a thing (the autocmd does not work) when I open a .md or .tex file, but works fine for .py files: augroup filetype_python autocmd FileType python ...