Setting up Vim workspaces for programming in multiple languages?

I'm new to Vim and I just set it up to write Python code, with code completion, bending, etc., and I can compile it also with a shortcut via plugins. The thing is, I would also like to write HTML / CSS in Vim and I would like to install some similar plugins. I know I can do this and set up different shortcuts for each language, but I would like to set it up in two separate workspaces to work in either a python workspace or html, but not both. Is there any way to do this? Thanks in advance!


source to share

1 answer

What are compiler scripts for?

The idea is to put a "compiler script" in your vim compiler directory. This script is actually a settings file (the difference between script files and settings files in vim is only conceptual - they are technically the same), just like your file .vimrc

. This script should contain configurations that are only loaded when you want to use them. For example, it :compiler python

loads your python settings.
For more information visit :help compiler


There are also "file plugins" - the main difference between them and compilers is that they are automatically loaded using vim's file detection engine - in fact, this is an extensive set of scripts that can detect almost any type of file - unless you are using an exotic language or define your own extension, and even then you can extend this mechanism with your own scripts ftdetect

. This is in contrast to compiler scripts, which must be explicitly invoked with a command, :compiler

or determined :autocmd

which invokes the command :compiler

For details see :help filetype


Compiler scripts are more suitable for compiler-specific options like as make

well as build / run keyboard shortcuts and file type plugins more suitable for settings. It makes sense to build a C program just as if you were in a file, .c

or .h

if you were in a makefile, or if you were in one of the program resource's text files.
Filetype scripts are more suitable for certain file types, such as syntax or code completion. It doesn't make sense to use C syntax and code completion for a C makefile or file .ini


That said - for interpreted languages ​​it doesn't really matter (unless you use a makefile to run them)



All Articles