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
2answers
173 views

Tab completion for filetypes in the commandline

If I want to set the filetype manually in vim, I would like to tab complete filetypes vim recognizes. However, right now vim just inserts a literal ^I :set ft=markd^I Is this possible?
32
votes
3answers
15k views

How do I tell vim that some file extensions are synonymous?

I edit C++ code in .cpp files, while template code goes into .tcc files. When I open such a file, no syntax highlighting is available. I tried set syntax=cpp in a a tpp.vim file in ~/.vim/ftplugin/, ...
0
votes
1answer
198 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 ...
6
votes
2answers
214 views

Identify if a buffer is CtrlP or not

I use a autocmd to display current tag via Tabgar plugin like this: autocmd CursorHold * call TagbarCurrentTag However, after I open CtrlP with :CtrlP for a while, the Tagbar's output No current tag ...
3
votes
3answers
573 views

Vim can't detect if a file is vim file type by commenting a file with vim:ft=vim

It used to work by adding following line into a file even it has no suffix .vim, my vim version is v8.0.1500, on OS X 10.13.3 " vim:ft=vim UPDATE: I tried adding following two lines to $MYVIMRC, ...
5
votes
2answers
2k views

Is there any list of filetype extension names?

I was told when add a line like # vim: filetype=r in a file, vim can recognizes the file type. It seems that for some files like *.cpp,*.java, vim can recognize the file while for files like *.CPP, *....
2
votes
0answers
583 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 ...
4
votes
1answer
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 ...
5
votes
3answers
985 views

Is it possible to create a function with the same name for different filetypes (and different implementations)?

Is it possible to create several functions with the same name whose implementation depends on the file type? For example, I could imagine a function named CurrentFunctionName that returns the name of ...
5
votes
1answer
400 views

Why does the "rst" filetype automatically indent subsequent list items?

I've been having trouble understanding the behavior defined in GetRSTIndent() in indent/rst.vim. I'm specifically using Neovim v0.2.2, but I believe this file has not changed between Vim/Neovim. ...
3
votes
0answers
65 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 ...
3
votes
1answer
1k views

How to reload the current file to change syntax highlighting (ex: adding a shebang)?

I always prefer shebangs over extensions. A lot of times I make a new file without an extension in vim, which gets opened as plain text, since no extension is provided, which is completely normal. ...
1
vote
1answer
155 views

formatoptions for hybrid (short markup + long paragraphs) content

I am trying to write my PhD thesis in vim using LaTeX So the documents will have two distinct types of content - markups that are relatively short, and paragraph text that is rather long. \begin{...
0
votes
1answer
73 views

Disabling indentation for filenames without suffix

VIM's Wikia documentation states that you can disable indentation for certain filestypes by inserting the line let b:did_indent = 1 in the file ~/.vim/indent/<filetype>.vim where <filetype&...
3
votes
1answer
8k views

Why files in `~/.config/nvim/after/ftplugin/` are not taken into acount?

My neovim doesn't load file type plugins when loading a ruby/eruby file. Here is the corresponding configuration files: for f in ~/.config/nvim/after/ftplugin/* ; do echo "# $f" ; cat $f; done # /...
0
votes
2answers
99 views

Scons files not recognised as Python but as conf

Neovim assigns a file type of "conf" to SConscruct and SConscript files -- aka the scons configuration scripts. This is wrong. It should be Python. I tried adding: au BufNewFile,BufRead SCons* setf ...
3
votes
1answer
857 views

Set formatoptions for a specific file

In my ftplugin/plaintext.vim script, I have the formatoptions set for editing mostly prose: setlocal formatoptions=tcroqan1j However, in very specific instances -- particularly, Python's idiomatic ...
18
votes
1answer
3k views

For an autocmd in a ftplugin, should I use pattern matching or <buffer>?

I have an autocmd for TeX and Markdown files to save the file automatically. Nothing unusual: autocmd CursorHold *.tex,*.md w However, as custom settings for these files increased, I split them off ...
3
votes
2answers
569 views

Are commands in filetype plugins rerun every time the buffer is loaded?

Every time I switch back and forth between two buffers, vim tries to re-load some file specific commands. The error message is E174: Command already exists: add ! to replace it` I am using ...
2
votes
0answers
437 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 ...
11
votes
1answer
6k views

Why is "set noexpandtab" in my ~/.vimrc ignored when I open a file? [duplicate]

I'm using Mac OS X 10.12 and I have set noexpandtab in my ~/.vimrc There are 2 different behaviors : $ vim file.py If run Vim (8.0) to open one file and type :set expandtab?, it says expandtab $ vim ...
3
votes
2answers
711 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
2answers
437 views

Vi/Vim 8 on debian stretch : filetype "bindzone" not loaded automatically

When opening a bind zone file, I have to type by hand :set ft=bindzone to get syntax highlighting. It's not set automatically on load. On another hand others filetypes (such as php, perl or kind) are ...
0
votes
1answer
106 views

Open One File-type per Tab

In vim you can open all files in present directory with vim *. All of a specific file type in directory with vim *.py. Recursively we use vim **/* and vim **/*.py. To open all files in tabs vim -p *...
0
votes
1answer
1k views

How to correctly indent when beginning a new line below the cursor ('o')? [duplicate]

Screenshots My problem I am working on a js file, using eslint as my linter with the ale plugin, configured using the airbnb standard which mandates 2 space indentation. When I open a new line by ...
1
vote
3answers
1k views

How to remove every second column in Vim?

I have a CSV file where I want to remove every second column. Each column value are separated by quotes and the column values can contain field separators: this means that convenient solutions such as ...
3
votes
4answers
2k views

Autocmd on directory to replace netrw

I use the ranger plugin wich I can trigger with a shortcut. But when I open a directory I would like to use the plugin instead of netrw. So I have found that the filetype of directories is netrw, ...
3
votes
2answers
1k 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 ...
1
vote
2answers
885 views

Display enclosing namespace, class, and function

How can I convince Vim or Neovim to show the enclosing namespace, class, and function that the cursor is in? Some programming languages have no interesting namespaces or class names. In general, this ...
1
vote
2answers
415 views

Set folding method for c and cpp files, but not h and hpp

I am in the process of customizing my vim setup, and since I write a lot in C, I have a whole function dedicated just for those files, which I call with autocmd filetype c,cpp,h,hpp call C_syntax(). ...
1
vote
0answers
88 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 ...
1
vote
1answer
954 views

Adding multiple syntax group to a syntax region

I’m writing a syntax file for Bats. I started my syntax file by loading the bash syntax: let g:is_bash=1 runtime! syntax/sh.vim unlet b:current_syntax I then defined the Bats custom keywords: ...
0
votes
1answer
746 views

NeoVim ftplugins Not working - Arch Linux

I have been using vim for a while on Arch Linux and decided to make a shift to Neovim. It's mostly working fine. The vimrc is sourced and thus all my configuration files and plugins are working fine, ...
1
vote
0answers
736 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 ...
3
votes
2answers
884 views

Selectively enable a subset of vim plugins for specific category of workflows (plugin virtualenv for vim projects)

I use vim for many different categories of projects, typically: Writing code (3 languages, python, Matlab and C) Writing documentation ( .rst, .html) Writing reports (.tex) Readme file (.md) As a ...
1
vote
1answer
295 views

Vim typescript files doesn't open first time

I have a strange issue with TypeScript or .ts files in terminal vim. I tried opening it from NERDTree or Control+P. It finds the file but for some strange reason after I hit the Enter key from ...
2
votes
1answer
161 views

How do I test ftplugin scripts efficiently

Say I am writing a plugin and constantly editing scripts in ftplugin. How do I efficiently test the changes? I can't simply source the editted file because they are filetype-specific. For example, if ...
2
votes
1answer
2k views

Set mappings depending on file type

I'd like to set some file-type dependent mappings to quickly run files. For example, I have some mappings like these: nnoremap <silent><leader>z :w<CR> :!clear; gcc %; ./a.out<cr&...
4
votes
1answer
897 views

Change the filetype based on tags / regions in the file

Recently I've started up with vuejs and I'm currently trying to set up my editor for using it. Vue uses a similar approach with React - keeping the HTML, Javascript & CSS in the same file - it ...
17
votes
3answers
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 ...
57
votes
1answer
36k views

What is the difference between `filetype plugin indent on` and `filetype indent on`?

I see one of these two lines in .vimrc files. This one seems to be most common: filetype plugin indent on But how does it differ from this line: filetype indent on I've found documentation for the ...
1
vote
1answer
250 views

Enable templating language (e.g., Liquid) syntax highlighting but keep native (html/css) commenting?

I just started working with Jekyll, which uses Liquid. As a templating language, Liquid is embedded into files of other types (e.g., HTML, CSS, or Markdown). Vim handles this sort of dual syntax ...
6
votes
1answer
2k views

How to force Vim to open given file as another filetype? (e.g. .txt.gz?)

Problem: I have .glabels generated files, which are gzipped xml. When I rename file to have suffix .xml.gz, then VIM properly recognizes file and it's editable, human readable xml. After edit I have ...
0
votes
1answer
250 views

Remove colon from keyword in C++ file?

: is set as keyword (set iskeyword) for C++ source file by default, is there a way to just disable that in my .vimrc file instead of doing set iskeyword-=: every time? It seems the plug-in set the ...
1
vote
1answer
458 views

How do I use regular expressions in ternary statements / keymappings?

I'd like to create a keymapping with a conditional statement, so that it behaves differently when a given line is blank. This thread gave me the following snippet, which is great – except that it ...
1
vote
1answer
332 views

Vim indent rules apply to existing files but not to new ones

vim-erlang-runtime is set up for indenting Erlang files that works for already existing files and does not work for any newly created ones. To elaborate, when starting a function body whenever I ...
1
vote
0answers
162 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?
1
vote
0answers
89 views

Strange behaviour when editing c and cpp files after update [closed]

After updating vim, it behaves very irrationally when I try to edit a c or cpp file. Here is a picture: I have tried to debug a bit, and both vim -u NORC -N --cmd 'call pathogen#infect()' file.c ...
3
votes
1answer
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
0answers
204 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 ...