I’m pretty new to Vim and I just set it up so that I can write Python code, with code completion, folding, etc. and am able to compile it also with a shortcut via plug-ins.
The thing is, I would also like to write some HTML/CSS in Vim as well and I’d like to install some similar plug-ins. I know that I could do this and configure different short-cuts for each language, but I’d like to set it up into two separate workspaces, so that am either working in my python or html workspace but not both. Is there any way to do this? Thanks in advance!
I’m pretty new to Vim and I just set it up so that I
Share
That’s what compilers scripts are for!
The idea is to put a “compiler script” in your vim’s compiler directory. That script is actually a settings file(the difference between script files and settings files in vim is only conceptual – technically they are the same), just like your
.vimrcfile. That script should contain configurations that are only loaded when you want them to. For example:compiler pythonloads your python settings.Check out
:help compilerfor more info.There are also “filetype plugins” – the main difference between them and compilers is that they are loaded automatically by the vim’s filetype detection mechanism – which is actually an extensive set of scripts that can detect pretty much any filetype – unless you use an exotic language, or define your own extension, and even then you can extend that mechanism with your own
ftdetectscripts. This is different from compiler scripts, which you need to explicitly call via a:compilercommand, or define an:autocmdthat calls the:compilercommand.Check out
:help filetypefor more info.Compiler scripts more suitable for compiler-specific settings like
makesettings and build/run shortcuts, and filetype plugins more suitable for settings. It makes sense to build a C program the same way either if you are in a.cor.hfile, if you are in the makefile, or if you are in an one of the program’s resource text files.Filetype scripts are more suitable for filetype-specific settings like syntax or code completion. It doesn’t make sense to use C syntax and code completion for a C program’s makefile or
.inifile.That said – for interpreted languages it doesn’t really matter(unless you use a makefile to run them)