Create custom ruby text transformations in Rubymine - ruby-on-rails

I thought this would be something built in and easy to do in Rubymine but I haven't been able to find any references to it let alone possible answers. Maybe I am phrasing my searches all wrong? I want to create a simple ruby script that I can use to transform text in Rubymine. I have to do a lot of snake_case to titleize transformations in my writing of some rails forms. I wish I could highlight some text and right click -> Titleize and have it happen, but Rubymine only does upcase/downcase or snake_case/camelCase conversions. It seems like I should be able to write a simple script like:
require 'active_support'
gets some_string
some_string.titleize
and assign it to a menu item. Any ideas? Right now I open the terminal panel in Rubymine where I have rails c running and copy/paste -> .titleize -> copy/paste.

I don't believe there is a way to do this right now using ruby. The use of RubyMine macros is quite limited, think you could take a look to some simple plugin like CamelCase take it apart and see what they are doing, but that would force you to use Java I guess.
However if you are interested only in the specific case of
snake_case > Snakecase
For that you could install the CamelCase and record a macro and assign it to a any shortcut you like , the macro itself would do this
ALT+SHIFT+U > SnakeCase
CTRL+SHIFT+U > snakecase
ALT+SHIFT+U > Snakecase
Hope that helps.

Related

Komodo IDE Ruby on Rails Editor auto-insert code issues

I've searched all over this site, and since I don't know what this particular function is called, I'm not sure how to find the answer, so apologies if this is a repeat.
I'm a new Ruby On Rails dev using Komodo IDE. When I type something such as
def full_title
it auto-inserts a bunch of crap until the text looks like:
def fulll_title(args)
#code
end
How do I either get rid of the (args) and (#code) or make use of them? Having to manually delete that junk is getting really, really old. I'm fine with either solution as long as there IS a solution. I don't even know what that particular feature is called, so I'm having a really hard time Googling/finding the answer on my own
Komodo IDE calls this feature code intelligence, and here are a few unrelated questions on controlling it:
Komodo Edit disable autocomple
Calltips/Docstring while viewing function list?
Komodo Edit macro to replace a specific word in current document with clipboard content; is it possible?

How to get the rails.vim-command :Rview working with .js.erb-views?

I want Rview to jump to .js.erb-views as well.
It always says "Can't find file "app/views/examples/foo".
The help says:
rails-template-types
Commands like :Rview use a hardwired list of
extensions (erb, rjs, etc.) when searching for files. In order to
facilitate working with non-standard template types, several popular
extensions are featured in this list, including haml, liquid, and mab
(markaby). These extensions will disappear once a related
configuration option is added to rails.vim.
Since the view ends with .erb, i would suggest it should work.
Any Ideas?
This is strange, I just checked in my vim and it works fine. I use Janus, but I think that the standard vim + rails.vim should work well.
Maybe you need to update rails.vim?
And you can tell the sequence of your actions: the current file, typed commands, etc.

In rails.vim why do I get "E345 can't find file in path" errors?

I've been learning Ruby/Rails with vim. Tim Pope's rails.vim seems like a really good tool to traverse files with, but I keep getting these pesky "E345 can't find file in path" errors. I'm not vim expert yet, so the solution isn't obvious. Additionally, I've tried this and it doesn't apply to my problem.
As an example of the problem. I have a method format_name defined in app/helpers/application_helper.rb and it is used in app/helpers/messages_helper.rb. Within the latter file I put my cursor over the usage of format_name and then hit gf and I get that error. Similar disfunction with commands like ]f and [f
However, it works sometimes. I was able to gf from user to the app/models/user.rb
Ideas?
I think that is a limitation of rails.vim. It does not support “finding” bare methods. Supporting something like that would require one of the following:
an exhaustive search of all the source files for each “find” request
(which could be expensive with large projects),
“dumb” indexing of method names
(e.g. Exuberant Ctags and gControl-]; see :help g_CTRL-]), or
smart enough parsing of the code to make a good guess where the method might be defined
(which is hard to do properly).
If you know where the method is, you can extend many of the navigation commands with a method name:
:Rhelper application#format_name
But, you do not have to type all of that in. Assuming the cursor is on format_name you can probably just type:RhTabspaceappTab#Control-R Control-W (see :help c_CTRL-R_CTRL-W).

vim/macvim: locate where a method/symbol is defined

I'm using macvim/vim for most of my Ruby + Ruby on Rails development. Is there currently a way to jump to where a method was defined within a project, even if it's not in the same file as where it's being invoked? Either a language agnostic way or a Ruby/Rails specific way works.
I recommend using the ctags plugin, Bryan Liles put together a nice screencast on how to use it with rails development.
http://smartic.us/2009/04/05/using-ctags-in-vim/
From his page:
Not-so-complete cheat sheet:
^] – find a tag
^T – go backwards
:tags – show where you’ve been
:tag – go somewhere in your tag stack
:tselect or g] – show where something is referenced
^W-] – find a tag in a split window
You can also have a look at the vim help by running: help :tags
EDIT:
Here is a nice screencast on updating your tags file automatically http://smartic.us/2009/04/03/creating-ctags-with-git-hooks/

Problems with Netbeans re: Rails erb/rhtml intellisense?

I've been using Netbeans for Rails and like it a lot, considering how little I paid for it. But something that bothers me is that when I'm editing an RHTML or ERB file, it doesn't do the code autocomplete - or at least not reliably. Sometimes it shows the appropriate variables and methods that are available on an object after you type the dot operator. Sometimes it ignores the instance variables. Is there a solution for this? (Please don't say RadRails).
Oh and one more thing in case anyone has solved this: considering how often I have to type <% when I'm in a Rails template, I wish there was some hotkey for autotyping the tag . . . ? I always have to stop and look down at my keyboard to find the < and % keys before I can type the tag so it's not as trivial as it might sound.
I believe you're looking for something like this:
http://ruby.netbeans.org/codetemplates-rhtml.html
Type in one of the triggers, then hit the tab key to expand it to the code as given.
Also, you might want to explore using HAML. It's much easier on the hands.

Resources