How do I lookup custom methods in RubyMine? - ruby

If there is a method like def cookie_monster somewhere in the project and I'm in a file which is using cookie_monster, how do I quickly find the file and line where cookie_monster is defined?
I saw "Navigate Code, Not Text: How to Navigate Effectively in RubyMine" from PivotalLabs which says I can use command + option/alt + O but perhaps my key mappings are different (default RubyMine 6). That does nothing for me.

Well I see you got your answer, but that isn't really the best solution, rubymine already caches all the function names and index it to find it fast without doing a search, try this method instead, it should be faster
Navigate -> Symbol
You'll get a small popup search bar, as soon as you write cook you should probably find your function in an auto complete, depending on your layout settings you'll find a nice shortcut to open it.
As a plus there's also
Navigate -> File
I never search for a file on the side bar to navigate, use this, it's always faster and will list all files with auto complete
The normal find function mentioned is used when you're trying to find a normal line of code, not a name of a function or a file.
Note that in both these popups you don't need to write the full name, for example to open the cookie_monster function, you can search for it as this comon ( co for cookie, and mon for monster ) you'll find it fun and very fast.
As for the find usages it's common usage for me is to find where a certain partial is called, or a certain function is used.

Select the word.
Edit -> Find -> Find Usages
or
Edit -> Find -> Find in Path
For keyboard shortcut, use the one against the menu.

Related

Can I rename a class and all its occurences/references in VS code?

I would like to rename a class that is a part of a huge project. I have IntelliSense, IntelliPhense and all related installed.
The project is Laravel, although there's a ton of custom code as well.
Is there a suggested extension or built-in way to do that, because I couldn't find any?
I think you can use the general search and replace on vscode by using ctrl + shift + F and you can skip (close) whichever you think its not part of what you wish to replace.
Here the total occurrence of TransactionController 31 and found in 5 files, you can close any file you don't want to replace the name.

SublimeText 3, how to navigate between files in project

I'm new to SublimeText (migrated from TextMate) and it's awesome.
But I'm familiar with JetBrains IDE and I need functionality to quickly open a file/class in a project. SublimeText provides cool features, like open symbol anywhere, goto anything and so on, but I can't find anything to open just files in a project.
When I'm working on a big project – goto anything and similar are not suit for me.
For example, I have a class named Data. When I'm trying to open that class with 'goto anything/symbol in project' – I got a lot of variables and methods in the list, because 'data' is pretty common word in programming.
So, I'm trying to achieve functionality to open only classes/files, without searching inside of them (like JetBrains Navigate -> Class). Is there any built-in functionality, or I need to write a custom plugin for my needs?
I threw the following together so you have an idea of something you can do. It might work well enough for you, if not, perhaps you can build off of it. This will grab every file, so perhaps you will want to add some sort of ignore patterns. If I recall, JetBrains works like that. For one shortcut it searches everything, for the other, just classes (well indexed files is probably more accurate)
import sublime_plugin
import os
class FileNameBasedOpen(sublime_plugin.WindowCommand):
def run(self):
self.input_content = []
for folder in self.window.folders():
for root, dirs, files in os.walk(folder):
for f in files:
self.input_content.append([f, root])
self.window.show_quick_panel(self.input_content, self.on_select)
def on_select(self, index):
if index == -1:
return
else:
f = os.path.join(self.input_content[index][1], self.input_content[index][0])
self.window.open_file(f)
Just figured that out. CMD + T, like TextMate.

Multi-file search in vim

I am comfortable with vim for normal editing.
I still need to use BBEdit for a few things. Mainly multi-file search. I provide it a folder listing of XCode project and what I want to search for and it produces a listing of files that I can do down through and do whatever.
http://www.mactech.com/articles/mactech/Vol.21/21.02/BBEditDoesntSuck/figure3.jpg
Can I somehow do this in vim? I am using the new maximum-awesome version released by Square: https://github.com/square/maximum-awesome
Given that maximum-awesome includes the ack plugin and the silver searcher package, :Ack string is the easiest way to do this. It also includes unimpaired plugin, so you can navigate the results (in clist) using [q and ]q. :help unimpaired, :help ack.
Don't use that silly distribution, it may feel like a convenient shortcut at first but it will slow you down. Configuring Vim and installing plugins yourself according to your needs is a large part of the learning experience. Skip that part and you'll be hooked to plugins and to someone else's tastes without getting the chance to actually learn to use Vim.
Case in point:
Vim does exactly what you want without plugins.
:vim foo **/*.m | cw
searches for foo in every *.m file under the working directory and opens the quickfix window if matches are found.
See :help file-searching and :h :vim grep.
You have installed a distribution that comes with 35 plugins without even reviewing them and deciding if they are worth installing or not or even actually read up on what they do. One of those plugins, Ack.vim, is there specifically to provide a streamlined (and fast) project-wide search experience. You should read its documentation, :help ack.
And, maybe, try the standard method before you get too used to Ack.vim.
You can use vimg for multi file search.
vimg /search string/ **
** makes it recursive for all file types
**/**.java if you want to search recursively for all java files
* if you want to search current working directory only
copen to open search results
cnext to see next match
cprev to see prev match
cclose to close search results

Steps to compare notebooks in Workbench

What, exactly, are the steps involved in using Wolfram Workbench (version 2) to compare two notebooks?
Please be explicit even in such things as what I do in order to open the two notebooks in Workbench.
(I find Workbench fiendishly difficult to use. Its built-in documentation is, I find, of limited value. The tutorial screencasts about it are just too rushed to be able to follow, even with stopping and starting. And there's still a confusion, at least for me, among various versions of sample files that are to accompany the tutorial.)
I have never used the workbench but when I fired it up I was comparing documents in minutes, so it can't be that hard.
The steps:
Create a project using the File > New > New Project menu (EDIT: many project types will do I think. I have tried both the Application and the Basic Mathematica type)
Add the two files to be compared to the project using import (in the File menu or the right mouse button context menu). EDIT: The best approach is probably using "General/File system". It will ask for a directory to import from. After that you may select the files you want to import from that directory.
Select both files in the package explorer view
Right mouse button > Compare with> Each other
Compare editor fires up showing the two documents side by side
(Welcome to StackOverflow Murray, it's good to see you here!)
This is not a direct answer to your question, but I think you might find it useful to know that the << AuthorTools` package includes functionality for comparing notebooks. Evaluate the following to open the ("hidden") documentation:
NotebookOpen#
FileNameJoin[{$InstallationDirectory, "AddOns", "Applications",
"AuthorTools", "Documentation", "English", "AuthorToolsGuide.nb"}];
Then you can compare them using CreateDocument#NotebookDiff[notebook1, notebook2], or perhaps using the somewhat more convenient
CreateDocument#NotebookDiff[SystemDialogInput["FileOpen"], SystemDialogInput["FileOpen"]]
which will let you select the files more easily.
Alternatively, you can open the two notebooks in the front end, and use this little control panel:
Dynamic#Column[
{PopupMenu[Dynamic[nb1],
Thread[Notebooks[] -> NotebookTools`NotebookName /# Notebooks[]]],
PopupMenu[Dynamic[nb2],
Thread[Notebooks[] -> NotebookTools`NotebookName /# Notebooks[]]],
Button["Show differences",
CreateDocument#NotebookTools`NotebookDiff[nb1, nb2]]}
]
It's interesting to mention that in Mathematica 8 there's some undocumented notebook-related functionality in the NotebookTools context, including a NotebookTools`NotebookDiff[] function.
Related question: Is it possible to invoke Mathematica's diff functionality from the command line?

Include only certain file types when searching in Visual Studio

Often when I want to search through my code in Visual Studio, I know the thing I'm looking for is in some C# code. However, as I've used the same variable name in a JavaScript file, I have to wade through all those search results too. This gets even worse when the text I'm looking for is also used in a third-party JavaScript library that we've brought into the project: this can result in hundreds of search results.
To compound things, our designers include HTML mock-ups of the pages in the same project, so I often find I'm hitting loads of search results in there too.
I guess what I really want is to see results in my .cs, .aspx, and .ascx files, but not .js or .htm.
Is there any way to do any of the following:
Search only in files of a particular type (search only .cs files).
Search only in files of any of a given set of types (search only .cs, .aspx and .ascx files).
Search in all file types except a particular type or types (search everything except .js).
I suspect not, in which case is there any crafty way of working around this?
In the Find in Files dialog (Ctrl+Shift+F), there should be a field called Find Options. You should be able to enter the extensions of fields you want to search in a field in this dialog:
*.cs; *.aspx; *.ascx;
Instead of Ctrl + F, I think it is Ctrl + Shift + F which gives you the choice to specify file types, you wish to look into.
You can choose file types from default or type your own. Regular expressions available for complex search.
Another way to limit file searches is by only choosing certain folder sets.
I like to exclude js files by using the following search:
*.a*;*.cs*;
Most of the times, I end up searching for stuff in aspx, cs, cshtml files so this is quite helpful.
Notice how I use *.cs* instead of *.c* since the latter would select jquery custom files such as jquery.custom1234.js (which I usually use in most of my projects), of course if you don't you could just use *.c*.
In the Find dialog box, go to "find options->Look at these file types".
Type in you own string, eg, *.cs, *.aspx, *.ascx. The click the "find all" button.

Resources