Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

filetype on or filetype off?

Tags:

vim

pathogen

I use the Pathogen plugin for gvim. When configuring I set the following in my vimrc file:

call pathogen#infect()
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()

filetype on  "force reloading *after* pathogen loaded

Now I'm following this tutorial on Youtube by Martin Brochhaus to set up Vim to be useful for Python coding and he suggests the following:

filetype off
filetype plugin indent on
syntax on 

So currently I have filetype on for pathogen but he is suggesting filetype off. What does this line of code do and how should I configure vimrc so Pathogen and Python are both happy?

like image 601
whytheq Avatar asked Jul 13 '13 12:07

whytheq


People also ask

What does filetype plugin on do?

filetype plugin on enables both filetype detection and filetype plugins, which are vimscript files that contain filetype-specific commands for setting various options, defining mappings, etc. Those ftplugins are located under $VIMRUNTIME/ftplugin/ and you can make your own under ~/. vim/ftplugin/ or ~/.

What is filetype off in vim?

But if you do switch off filetype detection, the indent files will not be loaded either. This actually loads the file "indoff.vim" in 'runtimepath'. This disables auto-indenting for files you will open. It will keep working in already opened files.

What does filetype indent on do?

It turns on "detection", "plugin" and "indent" at once. You can check for yourself by reading :help :filetype-overview .

Where is filetype vim?

vim (Unix-based systems) $HOME\vimfiles\filetype.


3 Answers

call pathogen#runtime_append_all_bundles()

is not needed at all: the function is deprecated and not useful anyway.

If you really need to be safe, this is what you should have at the top of your ~/.vimrc:

" turn filetype detection off and, even if it's not strictly
" necessary, disable loading of indent scripts and filetype plugins
filetype off
filetype plugin indent off

" pathogen runntime injection and help indexing
call pathogen#infect()
call pathogen#helptags()

" turn filetype detection, indent scripts and filetype plugins on
" and syntax highlighting too
filetype plugin indent on
syntax on

However, I've had the following for quite a while without any noticeable issue:

call pathogen#infect()
call pathogen#helptags()

filetype plugin indent on
syntax on
like image 105
romainl Avatar answered Sep 24 '22 22:09

romainl


The :filetype off is superfluous when immediately followed by :filetype [plugin indent] on (as it turns on filetype detection again, as described at :help filetype-plugin-on); don't blindly trust arbitrary resources on the Internet :-)

You usually want filetype detection (so that a corresponding syntax can be loaded for highlighting (with :syntax on)), and filetype-specific settings (the plugin part), and indentation rules (indent).

The only pitfall with Pathogen is that this should come after the Pathogen initialization, but you've done that right.

like image 25
Ingo Karkat Avatar answered Sep 22 '22 22:09

Ingo Karkat


filetype on enables filetype detection. Setting filetype plugin or filetype indent to on will turn on filetype detection if it wasn't already anyway. See :help filetype.

like image 38
Sam Nicholls Avatar answered Sep 22 '22 22:09

Sam Nicholls