Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [filetype]

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

0
votes
0answers
23 views

Use a file in ftplugin directory for multiple file types?

Let's say I want to use one file to set settings for xml, html, and plist files. So I have: .vim/after/ftplugin/xml.vim .vim/after/ftplugin/html.vim .vim/after/ftplugin/plist.vim But I want to join ...
0
votes
1answer
30 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 ...
1
vote
1answer
36 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
31 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 ...
4
votes
1answer
55 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
25 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
22 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
75 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 '...
1
vote
0answers
74 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
25 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> ...
0
votes
0answers
44 views

Specify a syntax checker for Chef on Vim with Syntastic

[Arch linux 4.18.14 with Vim 8.1 and Syntastic 3.9.0.] I am trying to configure the syntastic plugin on vim with a checker for Chef recipes. For that I installed the plugin dougireton/vim-chef inside ...
2
votes
1answer
163 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
69 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 ...
1
vote
0answers
80 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 ...
1
vote
1answer
279 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 ...
6
votes
1answer
211 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 ...
1
vote
1answer
197 views

What is the 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....
0
votes
0answers
126 views

Vim ignoring ftplugin

My settings in ftplugins are ignored. I have the following lines in my vimrc filetype on "enable filetype detection filetype plugin on "load plugins for specific filetypes filetype indent on ...
1
vote
0answers
34 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 ...
4
votes
1answer
108 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. ...
4
votes
0answers
47 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 ...
0
votes
1answer
32 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&...
0
votes
2answers
35 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 ...
2
votes
3answers
149 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, ...
1
vote
1answer
71 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
2answers
50 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 ...
2
votes
1answer
289 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, ...
0
votes
1answer
1k 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 # /...
2
votes
1answer
326 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 ...
1
vote
2answers
115 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?
1
vote
2answers
204 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 ...
1
vote
1answer
530 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/...
1
vote
0answers
107 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 ...
2
votes
1answer
1k 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 $ ...
0
votes
2answers
246 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
66 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
177 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
197 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 ...
0
votes
0answers
33 views

Ignore .sample on file name

I often create and read files with .sample appended to the file name. For example, php.ini.sample. I would like this to automatically show this as a .ini file. Similarly, if I were to view index.php....
2
votes
2answers
237 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 ...
5
votes
2answers
496 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
0answers
60 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
2answers
96 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
1answer
304 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
2answers
319 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
1answer
388 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
340 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
427 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 ...
8
votes
2answers
3k 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 ...
4
votes
2answers
332 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 ...