Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Cython PYXNew to Visual Studio Code? Get it now.
Cython PYX

Cython PYX

Jeff Baylor

|
1 install
| (0) | Free
Syntax highlighting, outline, and snippets for Cython .pyx, .pxd, and .pxi files
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Cython PYX VSCode Extension

Language support for Cython source files in Visual Studio Code.

Cython is a superset of Python that compiles to C, adding static C types, direct calls into C/C++ libraries, and GIL control.


Features

Syntax Highlighting

All Python syntax is highlighted by VS Code's built-in Python grammar. Cython constructs are layered on top and are recognised everywhere outside strings and comments — including inside parameter lists, brackets, and f-string interpolations.

Category Examples
Declarations cdef, cpdef, ctypedef, cdef class Foo, ctypedef struct Point, ctypedef fused real
C types int, double, bint, Py_ssize_t, size_t, unsigned long, int64_t
Typed memoryviews double[:, ::1], float64_t[:]
Casts <double>x, <Foo?>obj, <void*>p
Modifiers public, readonly, inline, api, const, nogil, noexcept, with gil
Exception specs except? -1, except *, except +, except NULL
C interop cdef extern from "math.h", namespace "std", cppclass, cimport, include
Builtins sizeof(), typeof(), address(), new
Directive comments # cython: boundscheck=False, # distutils: language = c++
Compile-time (deprecated) DEF, IF, ELIF, ELSE

Words that are ordinary Python identifiers (api, enum, struct, address, …) are only highlighted as Cython keywords in declaration position.

Outline

The Outline view, breadcrumbs, and Go to Symbol (Ctrl+Shift+O) list functions (def, cdef, cpdef), classes (class, cdef class, cppclass), structs, unions, enums, fused types, ctypedefs, and cdef extern from blocks with their declared functions.

Editing

  • Indentation-based folding, plus # region / # endregion markers
  • Auto-indent after a line ending in : (including cdef/cpdef/ctypedef blocks)
  • # line comment toggle, bracket and quote auto-closing

Snippets

Prefix Inserts
cdefclass Extension type with a typed attribute
cpdeffn cpdef function with exception spec
cdeffn cdef ... noexcept nogil function
cpdefmv Loop over a 2-D C-contiguous memoryview
cextern cdef extern from block
cimportnp NumPy import / cimport header
cython: Compiler directive comment
nogil with nogil: block

Supported File Types

Extension Description
.pyx Cython implementation file
.pxd Cython declaration file
.pxi Cython include file

Requirements

Python highlighting comes from VS Code's built-in Python Language Basics extension (present by default). If it is disabled, only the Cython-specific constructs are coloured. The extension has no runtime dependencies and does not run Cython.

Known Limitations

  • int, float, long, complex are always coloured as C types, even where they are the Python builtins.
  • A comparison written without spaces, a<b>c, is coloured as a cast.
  • Pure-Python-mode Cython (cython.int annotations in .py files) is not covered.

Building from Source

npm install
npm run compile   # tsc -> out/
npm test          # unit tests + grammar scope tests
npm run package   # produces cython-pyx-<version>.vsix

Install the .vsix via Extensions → … → Install from VSIX.

License

MIT

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