The usual way to compile from Vim is to use :make
. From :h :make
:
:mak[e][!] [arguments] 1. All relevant |QuickFixCmdPre| autocommands are
executed.
2. If the 'autowrite' option is on, write any changed
buffers
3. An errorfile name is made from 'makeef'. If
'makeef' doesn't contain "##", and a file with this
name already exists, it is deleted.
4. The program given with the 'makeprg' option is
started (default "make") with the optional
[arguments] and the output is saved in the
errorfile (for Unix it is also echoed on the
screen).
[...]
So, what I'd suggest is to set
makeprg
to tsc %
:
The ":make" command executes the command given with the 'makeprg' option.
This is done by passing the command to the shell given with the 'shell'
option. This works almost like typing
":!{makeprg} [arguments] {shellpipe} {errorfile}".
{makeprg} is the string given with the 'makeprg' option. Any command can be
used, not just "make". Characters '%' and '#' are expanded as usual on a
command-line. You can use "%<" to insert the current file name without
extension, or "#<" to insert the alternate file name without extension, for
example: >
:set makeprg=make\ #<.o
And then use :make
to save your file and build it, instead of :w
. (Or make a convenient mapping.)
:term
to have a shell running right in Vim.:make
for further explonation read the:he makeprg
also you can just run command:!tsc %