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
1
vote
1answer
302 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 ...
1
vote
0answers
56 views

Difference between &g:filetype and &filetype

Right now I have a python (*.py) file buffer open in a vim session. I also have the plugin startify installed. Now when I run the Ex-command: echo &g:filetype` I get startify. However, When I ...
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 ...
3
votes
1answer
49 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
2answers
22 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'...
1
vote
1answer
22 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
13 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?
8
votes
1answer
5k views

What is the difference between 'set ft=' and 'setfiletype'?

I am using vim 8.1. When I need to change the default filetype for .s extension to gas (which by default is asm), I first look for the default command to set filetype in /usr/share/vim/vim81/filetype....
1
vote
1answer
30 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
86 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 ...
1
vote
2answers
40 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
48 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
38 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
56 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 ...
10
votes
2answers
1k views

Use single ftplugin for more than one filetype

I have an ftplugin under &runtimepath/ftplugin/c.vim which sets all my preferred options for c files. However, I would also like to use the same settings for cpp files. I could just copy the ...
25
votes
3answers
6k views

Is it possible and useful to split vimrc?

As per the title, is it possible to split the vimrc file in several sub-files? Keep separate files for groups of settings that concern one thing? This thing might be anything, any kind of user-...
1
vote
1answer
50 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+=~/....
2
votes
1answer
147 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 ...
6
votes
2answers
2k views

How to create a new vim filetype?

I have html settings set up in my ~/.vim/ftplugin/html.vim file. I would like these settings to apply to Rhtml files as well. I made a symbolic link with ln -s ~/.vim/ftplugin/html.vim ~/.vim/...
8
votes
4answers
2k views

How do I define an autocommand to work on all files excepted a certain filetype?

For example, I have the following autocommand definition: augroup cursorline autocmd! autocmd WinLeave,BufLeave * set nocursorline autocmd WinEnter,BufEnter * set cursorline augroup end ...
86
votes
5answers
80k views

How to edit binary files with Vim?

Is there a way to edit binary files in some kind of hexadecimal mode? For example if I have some binary data shown by xxd or hexdump -C like this: $ hexdump -C a.bin | head -n 5 00000000 cf fa ed ...
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 ...
2
votes
2answers
91 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, ...
1
vote
2answers
139 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 ......
5
votes
1answer
1k views

In an autocmd what's the use of the BufRead event?

I'm trying to learn a bit of vimscript and currently reading the 12th chapter of Learn Vimscript the Hard Way. In this page, the author says : A common idiom in Vim scripting is to pair the ...
1
vote
1answer
133 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 ...
2
votes
0answers
196 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
50 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'...
3
votes
1answer
829 views

Vim never shows line number for Python files even though I have `.vimrc`

I found it strange that I can never have Vim show line number automatically for .py files, even if I have this as my ~/.vimrc set background=dark autocmd FileType py,c set number Strangely enough, ...
6
votes
2answers
723 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 ...
12
votes
2answers
9k views

What does “filetype plugin on” really do?

I understand that it loads the ftplugin.vim file, but what does it really do? Does it set options (depending on the filetype)? If I were to include this line at the start of my vimrc filetype plugin ...
1
vote
1answer
58 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 ...
38
votes
4answers
10k views

How can I change the default indentation based on filetype?

I'd like to have different indentations based on the type of file I am working on. For example, working on a .c file I'd like my indentation be 4 spaces. In .html files I'd like to (have to) work with ...
1
vote
1answer
239 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?
5
votes
2answers
1k views

How to make autocmd FileType work when a file has multiple / compound dot separated types?

While working a Markdown plugin, we've wanted to change the filetype from mkd to markdown to increase compatibility with other plugins. To avoid breaking users .vimrc that had autocommands like: ...
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
2answers
131 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
30 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. `$$...
9
votes
3answers
7k views

How can I make highlighting commands in .vimrc take effect immediately with Vim 7.4?

I have several highlight commands in my .vimrc file. In Vim 7.3, these took effect immediately after Vim had started. After updating to Vim 7.4, this is not the case anymore. Vim uses its default ...
1
vote
1answer
82 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
177 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! ...
10
votes
2answers
8k views

How do I run a specific vim command when opening a file with a given extension?

I want all of my files ending in .tex to have line length 80. So whenever I open a .tex file in vim I type :set tw=79. What would I put in my .vimrc to automate this? What if I wanted it to work with ...
0
votes
2answers
71 views

Unable to detect filetype which is set forcefully inside a custom plugin

I have following line in my vimrc- autocmd BufRead,BufNewFile *.COB,*.PCO set filetype=cobol "force filetype as cobol for .COB and .PCO files And I have put below lines in my custom plugin at the ...
0
votes
1answer
98 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 ...
-1
votes
1answer
186 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 '...
0
votes
1answer
95 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
75 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
35 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 ...