Hash and Curly Braces inside a Ruby String with snippets
Published on 08 May 2020
I was looking for a way to save myself an annoyance in Vim when interpolating a value inside a Ruby string.
Problem
GIVEN that the cursor is inside a Ruby string
WHEN I type #
THEN Vim should insert into the text #{}
AND my cursor should be between the curly braces
AND after I finish typing inside the curly braces there should be a way to jump out of them.
Solution
snippet #
#{${1}} ${2}
Thus, when I type #
-TAB
:
- Vim adds the curly braces
- Places the cursor inside the braces
- And when I finish typing, I can press tab to jump out.
I never used the original snippet anyway, because I use Tim Pope’s excellent plugin, Vim Commentary.
all tags
activerecord android annoyances api apt arch array artix atom az3w backend bash blog browser bug callback career cli cloud code coding config configuration cp crud css database db design devops django email erp filter fugitive gif gist git gnome grep hebrew http ide isbn-fetcher iso javascript job search js kanban kanban\ kindle koans linux logger manjaro map markdown microservices mobi mtp neovim nodejs packages pastbin patch post python rails reduce refactoring rest routes rspec ruby scripting security sed shell sql string_replacement study tdd terminal testing version_control vim walkthrough workflow