First time here? Check out the FAQ!
1

Do not understand how to create snippets with variables
 

I do not understand how to enter code for snippets with variable names. I create a new snippet and I get aan empty window in the editor. From there I would like to enter the code for a new test: def test_file_variable(self): string =

res = dstring_parse(string)
display_PathPoints(res, variable)

shouldbe = [

]
self.assertEqual(res, shouldbe)

I need a variable name instead of variable How can I do this?

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
piscvau's avatar
611
piscvau
asked 4 years ago
Wingware Support's avatar
4.3k
Wingware Support
updated 4 years ago

Comments

see more comments

1 Answer

0

The syntax is %(name|type|default)s and the type and default are optional. Examples:

  %(name)s
  %(created|datetime)s
  %(email||nobody@nowhere.com)s

You can also use environment variable references for the defaults:

  %(user||${USER})s

The documentation for this is at https://wingware.com/doc/edit/snippets and there are examples in the default set of snippets in the Snippets tool.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Wingware Support's avatar
4.3k
Wingware Support
answered 4 years ago, updated 4 years ago
link

Comments

Hello Please excuse me but I still do not understand and I am afraid I need more details. I did look into the documentation and the examples but it did not help. For example if I look at the 'from' snippet I see: |m|from %(module)s import |!| I see there a variable named module but I have not idea about what |m| and |!| is about. Coming back to my need for a snippet about a test, is I put %(name)s in the name of the function after def, I get a syntax error

piscvau's avatar piscvau (4 years ago)

|m| tells Wing to match the indent of the context when placing the snippet and |!| is the final resting place of the caret after data entry for the snippet is complete. These and the other syntax options are described in the documentation at https://wingware.com/doc/edit/snippet...

Wingware Support's avatar Wingware Support (4 years ago)
see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)