From 18e3cc18be8dbe25bb0862ca707f3e8c9779ab0b Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Sun, 1 Oct 2017 09:51:38 -0500 Subject: [PATCH] Add From Ruby Variables To JavaScript Variables as a vim til --- README.md | 3 ++- ...-ruby-variables-to-javascript-variables.md | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 vim/from-ruby-variables-to-javascript-variables.md diff --git a/README.md b/README.md index ca796f9..d00b286 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_568 TILs and counting..._ +_569 TILs and counting..._ --- @@ -585,6 +585,7 @@ _568 TILs and counting..._ - [Filter Lines Through An External Program](vim/filter-lines-through-an-external-program.md) - [Fix The Spelling Of A Word](vim/fix-the-spelling-of-a-word.md) - [Format Long Lines To Text Width](vim/format-long-lines-to-text-width.md) +- [From Ruby Variables To JavaScript Variables](vim/from-ruby-variables-to-javascript-variables.md) - [Generate and Edit Rails Migration](vim/generate-and-edit-rails-migration.md) - [Get The pid Of The Session](vim/get-the-pid-of-the-session.md) - [Go To File With Line Number](vim/go-to-file-with-line-number.md) diff --git a/vim/from-ruby-variables-to-javascript-variables.md b/vim/from-ruby-variables-to-javascript-variables.md new file mode 100644 index 0000000..e33d2ea --- /dev/null +++ b/vim/from-ruby-variables-to-javascript-variables.md @@ -0,0 +1,24 @@ +# From Ruby Variables To JavaScript Variables + +I sometimes find myself writing so much Ruby that as soon as I am back in +a JavaScript file, my code starts looking like this: + +```javascript +const my_javascript_var = 123; +``` + +It would be easy enough to hit `caw` to the delete the entire word and then +retype it as camel case. I happen to have the +[Abolish.vim](https://github.com/tpope/vim-abolish) plugin installed, so +there is an even quicker way. + +If I hit `crc` over the variable, it will be _coerced_ to camel case. + +```javascript +const myJavascriptVar = 123; +``` + +If I hit `crs` then it will be _coerced_ back to snake case. Hit `crc` one +more time and I can get back to writing some JavaScript. + +See `:h abolish-coercion` for more details.