I wanted to try out visual studio code for writing ruby/rails and came across this issue that when I write 'do' in the editor and then hit enter then 'end' is not automatically added to the next line.
Writing 'def' + enter works fine. 'begin' + enter works fine too, but not 'do' + enter.
I haven't found any extension that would make it work yet and google has not been much help either. Maybe there's a way to define the snipper myself?
Thanks in advance!
I found a workaround that suffices for now. Using Code -> Preferences -> User Snippers -> Ruby I added the following snippets
"Do block": {
"prefix": "dob",
"body": [
"do",
"\t$0",
"end"
],
"description": "Do block"
},
"Do block with params": {
"prefix": "dobwp",
"body": [
"do |${1:param}|",
"\t$0",
"end"
],
"description": "Do block with params"
}
The first one inserts a
do
end
without any parameters. The second one inserts a
do |param|
end
and you can choose the param value.
The downside is that when writing do you have to move down and choose dob or dobwp and it's not the default behaviour of do like in sublime.
Did you try https://github.com/rubyide/vscode-ruby ? It states that
This extension provides rich Ruby language and debugging support for VS Code.
including Autocomplete. Maybe worth a try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With