Installation, Tooling and First Program

2.1 Installation (from Source: Recommended)

Prebuilt binaries are available on GitHub Releases. Package managers (brew, AUR, scoop) are also an option but may lag.

V needs a C compiler. TCC ships with it for fast dev builds. Install GCC or Clang for optimized -prod builds.

git clone --depth=1 https://github.com/vlang/v
cd v
make                 # Windows: make.bat  (uses bundled TCC or your GCC/Clang/MSVC)
sudo ./v symlink     # adds `v` to PATH (Windows: .\v.exe symlink)
v version
v up                 # update V to the latest commit

2.2 The v Command

v run file.v / v file.v Compile and run / compile Build the module in the current directory v -prod file.v Optimized production build v fmt -w file.v Format code in place Lint for suspicious code Run tests (*_test.v) v doc module

v install pkg / v search / v update / v remove Package management (VPM) v new project / v init Scaffold a project

Environment diagnostics (for bug reports) v watch run file.v Recompile and rerun on file changes v translate file.c C → V translation (c2v) Rebuild the compiler v help <cmd>

2.3 Editor Setup

VS Code: the official "V" extension + v-analyzer (language server: completion, go to definition, diagnostics).

Vim/Neovim (vlang/vim-vlang plus v-analyzer via LSP), Emacs (v-mode), JetBrains (the IntelliJ V plugin), Sublime.

2.4 Hello, World

For single-file scripts, fn main() can be omitted:

// hello.v
fn main() {
	println('Hello, World!')
}
v run hello.v
v hello.v && ./hello
println('Hello from a script!')

2.5 V Shell Scripts (.vsh)

#!/usr/bin/env -S v run
// build.vsh: os module functions are available without a prefix
println(ls('.')!)
mkdir_all('build')!
result := execute('git log --oneline -1')
println(result.output)
chmod +x build.vsh && ./build.vsh

2.6 Reading Input

import os

fn main() {
	name := os.input('What is your name? ')
	age := os.input('Age: ').int()
	println('Hello, ${name}! Next year you will be ${age + 1}.')
}