Building code

Building doesn't necessarily apply to Python (since there isn't much compiling going on), but it's definitely worth going over to understand how Vim deals with executing code.

Vim provides a :make command, which wraps around the Unix make utility. In case you're not familiar, Make is a build management solution as old as time (and if it ain't broke...) that allows you to recompile parts of a bigger program (or all of it) as needed.

Some relevant options you'd want to be aware of are as follows:

  • :compiler lets you specify a different compiler plugin, which also modifies the expected format output for the compiler
  • In particular, :set errorformat defines a set of recognized error formats
  • :set makeprg sets what program to execute when running :make
Want to learn more about one of these options? Don't forget that you can run :help <anything> to look up an entry in the Vim manual.

The two can be used in conjunction to work with any compiler. For example, if you wanted to compile a C file you're working on, you could invoke gcc (standard issue C compiler) by running the following:

:compiler gcc
:make

What makes :make important is that it allows Vim users to implement syntax checkers, test runners, or just about anything else that spits out references to lines as a compiler plugin, giving us access to quickfix or location windows!

Terminal mode, introduced in Vim 8.1, is also a solid candidate for long-running builds, as :term make will call make asynchronously while you continue working on your code. See the Terminal mode section for more about terminal mode.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.120.133