Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Swap - Swahili Programming LanguageNew to Visual Studio Code? Get it now.
Swap - Swahili Programming Language

Swap - Swahili Programming Language

abdulbasit rubeiyya

|
229 installs
| (1) | Free
Syntax highlighting, live error checking, snippets, and a Run button for Swap, the Swahili-keyword programming language.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Swap — Swahili Programming Language for VS Code

Editor support for Swap (swapro on npm), the programming language that uses Swahili keywords for common programming constructs. Works with .sw files.

Screenshot

Features

  • Syntax highlighting for all of Swap's current keywords, built-in helper functions, strings, numbers, comments (#, //, and /* ... */), and operators.
  • Live error checking — diagnostics are powered by the real Swap interpreter's own lexer and parser (via the swapro package), not a re-implementation, so the errors you see are exactly what running swap file.sw would report. Checking runs on open, on save, and (debounced) as you type — no file is ever executed, so andika never prints and dai never blocks waiting for input.
  • Snippets for every core language construct (see table below).
  • Run button — a ▶ button in the editor title bar (also Ctrl+F5, or "Swap: Run File" from the Command Palette) runs your program in an integrated terminal, exactly like typing swap file.sw yourself. If the workspace has a main.sw, you'll be asked whether to run it or the file you're currently viewing; otherwise the current file runs directly. The file is saved first if it has unsaved changes. dai() input prompts work interactively in the terminal, same as the real CLI.

Note: the linter reports one error at a time, by design. Swap's real parser stops at the first syntax error it finds (there is no error-recovery step in the grammar), so this extension mirrors that exactly rather than guessing at further errors the interpreter itself wouldn't detect in the same pass. Fix the reported error and the next one (if any) will surface on the following check.

Requirements

None — the swapro language engine ships bundled with the extension as a dependency.

Keyword reference

Keyword Meaning
hifadhi declare a variable
andika print a value
kama / basi kama / basi if / else if / else
wakati while loop
hakika for loop
vunja break (only valid inside wakati/hakika)
chagua / kesi / zaidi switch / case / default
njia declare a function
rejesha return a value
kweli / sikweli true / false
lete import another .sw file
ita link a variable to its outer/enclosing scope inside a function, e.g. ita `x`
jaribu / kamata try/catch: jaribu { ... } kamata (err) { ... }
ramani declare a map/dict literal: ramani(ufunguo: thamani, ...) (keys are bare identifiers; access/set with mtu.ufunguo)

njia used where an expression is expected (e.g. hifadhi jumlisha = njia (a, b) { rejesha a + b; };) creates an anonymous function value (a lambda) instead of a named declaration — see the lambda snippet below.

Built-in helper functions

Helper Purpose
herufiKubwa convert a string to uppercase
herufiNdogo convert a string to lowercase
hariri replace a substring
tafuta find a substring (returns kweli/sikweli)
badili str_replace — simple, paired-array, global ("yote"), or regex replacement
pogoa trim leading/trailing whitespace
jaza pad a string to a target length
gawa split a string into an array
kaunta array length/count
ongeza push a value onto an array
toa pop the last value off an array
panga sort an array
unganisha join an array into a string
geuza reverse an array
kata slice an array
ramanisha map — build a new array by calling a function per element
chuja filter — keep elements where a function returns kweli
punguza reduce — fold an array to a single value
kilamoja forEach — call a function per element
zungusha / sakafu / paa round / floor / ceiling
kamili absolute value
kubwa / ndogo max / min of any number of values
kipeo power (kipeo(msingi, kiwango))
mzizi square root
ainaYa get a value's type name ("namba", "neno", or "orodha")
kwaJson serialize a value to a JSON string
kutokaJson parse a JSON string back into a value
mda date/time helper
kisia random-value helper
dai prompt for user input

Snippets

Prefix Inserts
andika print statement
hifadhi variable declaration
kama if / else if / else
wakati while loop
hakika for loop
chagua switch / case / default
njia function declaration
orodha array literal
kazitegemezi call to one of the built-in helper functions
jaribu try/catch block
ramani map literal
ramaniWeka set/add a key on an existing map
lambda anonymous function value (hifadhi x = njia (...) { ... };)
dai user input prompt
lete import another .sw file

Running a file

Click the ▶ button in the editor title bar, press Ctrl+F5, or run "Swap: Run File" from the Command Palette while a .sw file is open.

  • If your workspace root has a main.sw, you'll be prompted to run it or the file you're currently viewing (unless main.sw is already the one open, in which case it just runs).
  • Otherwise, the current file runs directly.
  • Output — and any dai() input prompts — appear in a "Swap" terminal, so you can type answers interactively just like running swap file.sw yourself.

For the full language tutorial and runnable examples, see the swap repository and its examples/ folder.

Contributors

Extension created by Abdulbasit Rubeiyya

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft