Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>Rusty SnipsNew to Visual Studio Code? Get it now.
Rusty Snips

Rusty Snips

Foobar Inc

|
69 installs
| (0) | Free
Various VS Code snippets for the Rust language.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

rustysnips

Various VS Code snippets for the Rust language.

Support for Selected Text

Many of the snippets will automagically surround the currently selected text with the snippet template code, but in order to get this to work in VS Code, you will need to do the following one-time configuration change:

  1. Open VS Code
  2. Press Ctrl + K followed by Ctrl + S (this should open the VS Code keyboard shortcuts page)
  3. Search for surround with snippet
  4. Assign a keybind of your choosing or use Ctrl + K Ctrl + M

Standard Process for Surrounding Selected Text with Snippet

After you have configured VS Code (see previous steps) and you have some selected text you want to surround a snippet with, then do the following:

  1. Press the keybinding you configured previously
  2. Type the snippet name or shortcut
  3. Select the appropriate snippet
  4. Press Enter

VS Code Snippets

block

What you type:

  • {
  • block

What you get:

{
  // new code block ...
}

Any selected text will be included in the new code block. Also, this snippet is smart and will automatically add a ; automatically if needed (e.g. you selected some text after the arrow in a match arm you want to turn into a code block).

error match

What you type:

  • error-match
  • em

What you get:

match <first tab position here> {
  Ok(<second tab position here>) => <third tab position here>,
  Err(<fourth tab position here>) => <fifth tab position here>
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

for in enumerate()

What you type:

  • for-in-enumerate
  • fien

What you get:

for (i, <first tab position here with default &item>) in <second tab position here; choose: iter(),into_iter(),iter_mut()>.enumerate() {
  <selected text goes here>
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

for in loop

What you type:

  • for-in-loop
  • floop

What you get:

for <first tab position here> in <second tab position here> {
  <selected text goes here>
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

if

What you type:

  • if

What you get:

if <first tab position here> {
  <selected text goes here>
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

if/else

What you type:

  • if-else
  • ife

What you get:

if <first tab position here> {
  <selected text goes here>
} else {
  
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

if let

What you type:

  • if-let
  • ifl

What you get:

if let <first tab position here; select: Some(), Err()> = <second tab position here> {
  <selected text goes here>
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

loop

What you type:

  • loop
  • lp

What you get:

loop {
  <selected text goes here>
}

match

What you type:

  • match
  • mt

What you get:

match <first tab position here> {
  <second tab position here> => <third tab position here>,
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

optional match

What you type:

  • optional-match
  • match?
  • mt?
match <first tab position here> {
  Some(<second tab position here>) => <third tab position here>,
  None => <fourth tab position here>
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

optional while

What you type:

  • optional-while
  • while?
  • ow?

What you get:

while let Some(<first tab position here with default: value>) = <second tab position here> {
  <selected text goes here>
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

println! macro

What you type:

  • print-line
  • println
  • pln

What you get:

println!("<cursor is here>");

struct declaration

What you type:

  • declare-struct
  • define-struct
  • ds
  • struct
  • stc

What you get:

struct <first tab position here with default: name> {
  <second tab position here>
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

trait declaration

What you type:

  • trait
  • tr

What you get:

trait <first tab position here with default: name> {
  <second tab position here>
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

while

What you type:

  • while-loop
  • wl

What you get:

while <first tab position here> {
  <selected text goes here>
}

Once the code snippet fills in the above code template, use the Tab key to quickly fill in the code.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft