Compile and run
nim c <file.nim>
Compile with the C backend
nim c -r <file.nim> <args>
Compile, then run with args
nim r <file.nim> <args>
Compile to nimcache and run
nim c -d:release <file.nim>
Optimized release build
nim c -o:<file> <file.nim>
Set the output file name
nim c --outdir:<dir> <file.nim>
Set the output directory
nim cpp <file.nim>
Compile via C++
nim js <file.nim>
Compile to JavaScript
nim c -d:danger <file.nim>
Optimize, all runtime checks off
nim c --opt:size <file.nim>
Optimize for size
nim c --app:lib <file.nim>
Build a shared library
nim c --app:staticlib <file.nim>
Build a static library
nim c -f <file.nim>
Force a rebuild of all modules
nim e <script.nims>
Run a NimScript file
Checks and flags
nim check <file.nim>
Check syntax and types only
nim c -d:<symbol> <file.nim>
Define a symbol
nim c -d:<symbol>:<val> <file.nim>
Define a symbol with a value
nim c --threads:on <file.nim>
Enable threads
nim c --mm:<orc|arc|refc> <file.nim>
Pick memory management
nim c --path:<dir> <file.nim>
Add a module search path
nim c --hints:off <file.nim>
Silence hints
nim c --warning:<name>:off <file.nim>
Switch off one warning
nim c --warningAsError:<w>:on <f.nim>
Make a warning an error
nim c -x:off <file.nim>
Disable runtime checks
nim c -a:off <file.nim>
Disable assertions
nim c --stackTrace:on --lineTrace:on <file.nim>
Trace lines in crashes
nim c --styleCheck:error <file.nim>
Enforce Nim naming style
nim c --parallelBuild:0 <file.nim>
Build with all cores
nim dump
Show defines and search paths
nim c --cc:<gcc|clang> <file.nim>
Choose the C compiler
nim c --passC:<flag> <file.nim>
Pass a flag to the C compiler
nim c --passL:<flag> <file.nim>
Pass a flag to the linker
nim c --nimcache:<dir> <file.nim>
Set the generated-files directory
nim c --cpu:<cpu> --os:<os>
<file.nim>
Cross compile
nim c -d:mingw <file.nim>
Cross compile to Windows
nim c --genScript <file.nim>
Emit a build script, no link
nim c --debugger:native <file.nim>
Build for gdb debugging
nim c --expandArc:<proc> <file.nim>
Show ARC/ORC lowered code
Nimble packages
nimble init
Start a new package (wizard)
nimble build
Build the package binaries
nimble run <bin> <args>
Build and run a binary
nimble test
Run tests/t*.nim
nimble install
Install the package in this dir
nimble install <pkg>
Install a package
nimble install <pkg>@<ver>
Install a specific version
nimble install --depsOnly
Install only dependencies
nimble uninstall <pkg>
Remove a package
nimble search <term>
Find packages by name or tag
nimble list -i
List installed packages
nimble refresh
Update the package list
nimble check
Validate the package
nimble tasks
List custom tasks
nimble <task>
Run a task from the .nimble file
nimble dump
Show package metadata
nimble path <pkg>
Print a package's path
nimble deps
Show the dependency tree
nimble publish
Publish to the package list
nimble build --useSystemNim
Skip Nimble's Nim management
Language basics
Variables
let x = 1 # immutablevar y = 2 # mutableconst z = 3 # compile time
Procs
proc add(a, b: int): int = a + becho add(1, 2)
Loops and collections
for i in 0 ..< 3: echo ivar s = @[1, 2, 3]s.add 4for x in s: echo x
Types
type Point = object x, y: intlet p = Point(x: 1, y: 2)
Strings
import strutilsecho "a,b".split(',')echo "x=$1" % "5"
Unit test
import unittesttest "adds": check 1 + 1 == 2