Questions tagged [filetype]

Questions about making Vim to have a defined behavior according the type of the edited file.

40 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10 votes
0 answers
981 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 ...
Hotschke's user avatar
  • 4,640
6 votes
0 answers
99 views

Filetype changes when using :split and :Explore

Why does using :split and :Explore cause the filetype to change? For example, edit a file named text.man, and the filetype is set to man. Change the filetype to txt, then :split and :Explore in the ...
xn.'s user avatar
  • 161
4 votes
0 answers
1k 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 ...
Brian Fitzpatrick's user avatar
4 votes
1 answer
313 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 ...
Shuzheng's user avatar
  • 1,195
4 votes
0 answers
1k 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 ...
Teodoro's user avatar
  • 153
4 votes
0 answers
66 views

Can I apply one file's filetype to another, without actually opening the first file?

For context, see How can I automate filetype detection when using sudoedit? Say filea has filetype foo, which is detected based on varying factors, including the name, the full path or the contents ...
muru's user avatar
  • 24.7k
3 votes
0 answers
72 views

Syntax-aware line wrapping

Is there a way to make the automatic line wrapping of vim aware of the syntax of the file instead of just wrapping at the closest whitespace? I am specifically interested in Python but I guess it ...
luator's user avatar
  • 141
3 votes
0 answers
660 views

in-line math equation rendering/preview for macvim/vim for filetypes other than RMarkdown

I recently installed vim-rmarkdown package, and found that the package allows me to see the rendered math equation in macvim, and when move cursor over, the line will render back to latex equation ...
Zoey A's user avatar
  • 31
2 votes
0 answers
173 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 ...
Zim's user avatar
  • 187
2 votes
0 answers
1k 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 ...
itsfarseen's user avatar
2 votes
0 answers
723 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 ...
Ul Tome's user avatar
  • 31
1 vote
2 answers
120 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 ...
Alex Roberts's user avatar
1 vote
0 answers
45 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 ...
markling's user avatar
  • 319
1 vote
0 answers
240 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 ...
haku's user avatar
  • 111
1 vote
0 answers
85 views

What could interfere with setting foldmethod=indent by autocmd FileType python?

So recently I noticed my autocmd FileType python setlocal foldmethod=indent is not working anymore. The version for my vim is 8.2 When I open a python file everything is working fine except the ...
cccplex's user avatar
  • 111
1 vote
0 answers
101 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 ...
Keyframe's user avatar
  • 111
1 vote
0 answers
116 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 ...
LazyLeopard's user avatar
1 vote
0 answers
123 views

Why is filetype not set after :find from autocmd?

Objective I want vi file to act like :find file if file doesn't exist. That is, I want to be able to edit a file by name, without giving a path to the file, from the command line: mkdir -p a/b/c ...
aghast's user avatar
  • 217
1 vote
0 answers
826 views

Syntastic not working with local eslint

I have a scenario where I have a local .eslintrc and the local eslint package installed. However, I notice that it does not populate a loclist on a file called app.js when I open the file and when I ...
vamsiampolu's user avatar
1 vote
0 answers
212 views

Weird characters are appearing while i move in blank spaces

When I exited Insert Mode I began to move around the file, these images began to appear. Does someone know how to fix it?
user3347359's user avatar
1 vote
0 answers
217 views

Some mappings in my .vim/ftplugin/*.vim change upon entering a window with different filetype, and some don't. What could be the reason for this?

I have special commenting macros for different languages in my ftplugin files, and macros for creating "dividers" (i.e. commented out line of dashes #--------...). I also define a Vimscript filetype ...
Luke Davis's user avatar
  • 1,397
1 vote
0 answers
75 views

filetype plugin not loaded on files opened with edit command

I've turned on filetype indent and plugins on with the following in my vimrc file: filetype indent plugin on Everything is fine when I open a file from terminal, but if I open another buffer ...
user4897's user avatar
0 votes
0 answers
19 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 ``` ...
January's user avatar
  • 263
0 votes
0 answers
108 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[...
Sam's user avatar
  • 101
0 votes
0 answers
41 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 ...
hermancain's user avatar
0 votes
0 answers
59 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;} ...
kongou's user avatar
  • 1
0 votes
0 answers
40 views

When I open a .txt file, the double quotes ( " )are suppressed

First, I tried on Linux: I opened a .txt file (or copy and past the text from a website) but the double quotes are not shown... On Linux, they are replaced by this: ~~@~~ On Windows 10 (I use gVim on ...
alexandre's user avatar
0 votes
0 answers
370 views

Setting ftdetect a given directory

I'm looking for a way to set filetype on load, a loading phase via ftdetect. Right now I can open the files inside a given directory via some utility function that I wrote, and during the opening ...
ekiim's user avatar
  • 133
0 votes
0 answers
55 views

Formatting with gg=G on *.cfg files (Nagios) results in bad indentation

Search-fu power is eluding me for this one. Have many Nagios (*.cfg) files under audit, using Vim to work on them. Notice that doing gg=G is not correctly formatting the files or a block if using = ...
alemani's user avatar
  • 101
0 votes
0 answers
105 views

Should an exclamation point be added after an "autocmd" in a filetypedetect augroup?

I'm trying to learn more about augroups, which have always confused me. The Section 43.2 documentation (:help 43.2) makes it clear that the filetypedetect group should be used to group autocmds which ...
John Karahalis's user avatar
0 votes
0 answers
198 views

How to apply existing indenting rules to new file type?

I've been happily using vim for years for C and C++ projects. My code formatting/indentation rules have been cobbled together over the years based on solutions to at-the-time needs...which is to say, ...
StoneThrow's user avatar
0 votes
0 answers
264 views

Let .js files be recognized as .jsx files?

I just figured out how to combine those creepy plugins to work together to achieve the following auto-indent: before / after pressing o: But then this only works on file extension .jsx as shown above,...
NeoZoom.lua's user avatar
  • 1,322
0 votes
1 answer
199 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 ...
paulSFO's user avatar
0 votes
0 answers
214 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 ...
Annibale's user avatar
  • 101
0 votes
0 answers
312 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 ...
gented's user avatar
  • 109
0 votes
0 answers
32 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 ...
David542's user avatar
  • 2,365
0 votes
0 answers
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 ...
ekiim's user avatar
  • 133
0 votes
0 answers
58 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 ...
Vitor's user avatar
  • 1,742
-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 #####. ...
newview's user avatar
  • 291
-1 votes
1 answer
82 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 ...
Nikola-Milovic's user avatar