Questions tagged [filetype]
Questions about making Vim to have a defined behavior according the type of the edited file.
210
questions
0
votes
1
answer
34
views
How to automatically close all the terminal buffers when closing vim with :qa?
I am wondering if there is a way to automatically force-wipe all the running terminals when quitting Vim with :qa.
My attempt (that does not work):
vim9script
def WipeoutTerminals()
for buf_nr in ...
-1
votes
1
answer
51
views
How can make the expansion to take effect in any type of file?
If I add the following lines in html.snippets:
snippet "(\S+)(\d+)" "Repeat token n times" r
`!p snip.rv = int(match.group(2)) * match.group(1)`
endsnippet
#5 can expand to #####.
...
0
votes
1
answer
21
views
Is there any way to set ccze color scheme?
I want to use ccze color scheme for log file specific.
augroup LogColorscheme
autocmd!
autocmd FileType log colorscheme ccze
augroup END
However, this installed color scheme on system-wide
...
-1
votes
0
answers
29
views
"New File" popup for templates [closed]
I have looked through a number of template plugins, and while they are cool, one thing I'm really looking to do is have the file automatically save in a specific directory with the provided name ...
0
votes
1
answer
165
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 ...
0
votes
2
answers
38
views
ftdetect, ftplugin not working as advertised -- what am I missing?
I've been reading documentation and trying experiments to register a new filetype in vim, and apply desired indentation rules -- all to no avail.
As an example, say I want to register *.test as ...
18
votes
3
answers
2k
views
Blocking changes to read only file
When using Vim to edit a read only file it will just provide a warning the first time it is edited but allow any changes to take place. I can understand this behaviour could be useful for someone ...
7
votes
2
answers
2k
views
Mardown files always have vimwiki filetype (vimwiki plugin)
Here is the relevant content of my .vimrc
let g:vimwiki_global_ext=0
let g:vimwiki_list = [{'path': 'C:\Users\<USER>\vimwiki',
\ 'syntax': 'markdown', 'ext': '.md'}]
The ...
1
vote
1
answer
24
views
What is changing the textwidth on rust files?
This seems like a bizarre behavior to me. I've set the textwidth to 88, but I've noticed that, when editing a .rs file, something sets it to 99. At first I though it must be some plugin or formatting ...
11
votes
3
answers
3k
views
Setting syntax in ftplugin
I’m trying to set the syntax of Processing files (*.pde) to java with a ftplugin.
.vim/
after/
ftdetect/
pde.vim
ftplugin/
processing.vim
In after/ftdetect/pde.vim I ...
5
votes
3
answers
2k
views
Syntax highlight fail for Prolog files
I'm having trouble configuring Vim on Manjaro:
After setting syntax on at .vimrc file, I make a Prolog program (bug.pl) which shows no syntax highlight:
But after I append /**/ to top of file (then ...
0
votes
0
answers
13
views
Creating a better ftplugin for rmarkdown
The Rmarkdown files have markdown formatting interspersed with R language chunks, denoted as follows:
# markdown header
markdown regular text
```{r}
# comment: some R code...
a <- pi * r^2
```
...
1
vote
2
answers
80
views
Editing .bib files in (n)vim with tailored autocompletion
I use BibDesk on a Mac to edit .bib files (in biblatex, using biber to compile). This generally works, but for various reasons it would be nice to be able to edit them in nvim too. My current setup ...
0
votes
2
answers
36
views
How to set all files under a folder to a specified filetype?
I have some zsh function files that I should not add extensions to for the convenience of calling, i.e. my_func instead of my_func.zsh. But this causes an issue that Neovim cannot detect their ...
0
votes
1
answer
43
views
Do I need to set `:filetype on` myself in Neovim?
As title. I'm a user of Neovim and am trying to learn something very basic. My point is that I don't want to set things that will be enabled by Vim by default. And what's the relation between
:...
4
votes
1
answer
238
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
1
answer
1k
views
Is it possible to set a vim.api.nvim_create_autocmd for a FileType (not just a pattern)?
Currently I'm using pattern in vim.api.nvim.create_autocmd():
vim.api.nvim_create_autocmd({ "BufEnter", "BufFilePost" }, {
pattern = { "*.tf" },
callback = ...
-1
votes
1
answer
47
views
Specific filetype files should end with new line
my work project requires a newline at the end of a file. If I add a new line and save, it gets automatically removed. I work in Golang but the same behavior is observed in Lua, Rust and probably ...
0
votes
1
answer
26
views
Is it possible to delete part of a wildcard autocmd?
If I put this
augroup AU_NAME
autocmd!
autocmd CursorMoved *.cpp,*.hs echo localtime()
augroup END
autocmd! AU_NAME CursorMoved *.cpp
in my vimrc, then open a file and enter :au AU_NAME, I see
--...
16
votes
4
answers
12k
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
4
answers
552
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 ...
2
votes
1
answer
336
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=...
3
votes
2
answers
1k
views
How to tell vim to behave the same for file extension .in and .mako
I noticed Vim will choose the correct syntax when I open a file that ends with .c.in or .pl.in.
I would like to tell Vim to behave the same with extensions like .c.mako or .pl.mako.
How is it ...
0
votes
1
answer
72
views
`au BufWritePost` equivalent that matches on FileType?
There are a few cases where the file extension isn't necessarily indicative of the file contents, and filetype needs to be set with a modeline. For example, Salt *.sls files can contain many ...
1
vote
2
answers
42
views
Set mappings dependent of file type
To execute and debug different kind of programs, I mapped the function keys in the .vimrc-file.
E.g.
" save and execute perl
:noremap <F5> :w<CR>:!./%<CR>
" save and ...
0
votes
3
answers
49
views
Output all filetypes into a file
echo getcompletion('', 'filetype')
The ex-command above lists all supported filetypes in vim. How can I output it into a file?
I tried these two ways but none worked.
echo getcompletion('', 'filetype'...
2
votes
1
answer
2k
views
How can I prevent the default loading of ftplugin/text.vim for certain *.txt files?
I have to edit a bunch of *.txt files for which I want to define a specific filetype. So, in my vimrc, I add a
autocmd! BufReadPost bunchOfFiles/*.txt :set ft=bunchOfFilesFT
This reads ftplugin/...
10
votes
0
answers
853
views
Support for embedded languages
Vim supports syntax highlighting for embedded languages or fenced code in markdown (:h :syn-include).
However, you usually want that other vim settings and mappings are adjusted for embedded languages ...
18
votes
2
answers
7k
views
How to tell Vim not to try to unzip a file?
I'm trying to open an .xlsx file in Vim, but got an error saying:
***error*** (zip#Browse) unzip not available on your system
I know it's a binary file, but I want to do some checksums and probably ...
1
vote
0
answers
30
views
Stop foldmarker inserting hash
I my folds are set with foldmarker={{{,}}}. When I create a fold it inserts a comment # char before the marker. So it inserts #{{{. How do I stop it doing this?
I have syntax highlighting (and it ...
0
votes
0
answers
78
views
Neovim recognizes LaTeX class files (.cls) as filetype=st
When I run nvim test.cls (a LaTeX class file looking something like this:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{landscapetest}[forcing landscape mode]
\LoadClass[landscape]{article}
\RequirePackage[...
0
votes
0
answers
27
views
How can I enable html autocomplete in .tmpl files?
I'm editing .tmpl files which are mostly html with some template language syntax inside {{ double curly braces }}.
I'm using COC for autocompletion and I want to be able to use the autocomplete ...
0
votes
0
answers
46
views
Vim automatically inserts "* " add the start of every new line in css files
If theres a "* " at the start of the previous line Vim automatically inserts a "* " at the start of the next new line. I want Vim to not insert anything.
examples:
1|* {margin: 0;}
...
0
votes
1
answer
80
views
How to disable spell check for certain file types
How can I disable spell check for files likes yaml, json?
1
vote
2
answers
97
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 ...
0
votes
1
answer
91
views
vim status bar not consistent in all file
I recently set my vim status bar using this:
" set status line
set laststatus=2
set statusline=
set statusline+=%#StatusLineFile#
set statusline+=\ %F
set statusline+=%m
set statusline+=%=
set ...
1
vote
1
answer
48
views
Is there a way to detect all the autocommand that have been triggered?
I have a file for which the filetype is not correctly set.
The filetype is set by an autocmd but I would like to identify which one.
How can I know which autocmd have been triggered when I load my ...
1
vote
1
answer
29
views
To not treat files like 'vimrc-tips.txt' as Vim Script files
There is a line in defaults.vim that enables Vim Script syntax for any .txt file with vimrc in its filename (for example, vimrc-tips.txt):
au BufNewFile,BufRead *vimrc* call s:StarSetf('vim')...
0
votes
2
answers
93
views
What is wrong with my autocommand groups?
This is the current state of my autocmds.vim file.
" Option for specific filetypes
autocmd BufRead,BufNewFile *.md setlocal textwidth=...
2
votes
1
answer
227
views
How can I enable .xml syntax highlighting for .xaml files?
I am trying to enable .xml syntax highlighting in Vim for .xaml files since .xaml files don't have syntax highlighting of its own. I came across a post on Stack Overflow which recommended to use au ...
9
votes
1
answer
1k
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 ...
1
vote
1
answer
1k
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 in this Stack Overflow answer
set nocompatible
filetype off
set rtp+=~/....
1
vote
0
answers
116
views
How to map keybindings only for specific file type?
In vimwiki, <C-x><C-o> provides available tags in autocomplete dropdown. I am attempting to map that key mapping to something easier like (ctrl+alt+space) and only when I am in a markdown ...
4
votes
0
answers
889
views
Can (Neo)Vim be configured to set the filetype according to the shebang?
Lately I've been using neovim to edit lots of files with the .tmpl extension. These files all have shebangs, most (but not all) of which are #!/bin/sh.
The default behavior seems to be that neovim ...
6
votes
1
answer
3k
views
In what order does Vim read ftplugin files, syntax files, and the .vimrc when the commands (e.g. set syntax=mysyntax, filetype plugin on) are called?
I've had some issues lately reconciling my .vimrc with files in ftplugin and after/ftplugin. In what order are all these things read?
For example: when I call in my .vimrc the command plugin filetype ...
1
vote
1
answer
106
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?
0
votes
2
answers
4k
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?
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 ...
5
votes
3
answers
1k
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
1
answer
61
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 ...