Most people say vim is greatest editor.
But is there any way to rename variable as fast as sublime.
Example:
function f($items) {
$items;
....
$items;
}
In sublime:
Go to items variable
click ctrl+d 2 times
rename variable
In VIM:
Search for /items
cw
write the new name
"n" for next occurrence and then "." to repeat
In vim obviously the keystrokes are more.
Does anyone knows easier and faster rename variable method?
Thank you
There are few solutions:
Change command
Go to items and then hit:
*Ncgn{new name}<Esc>
And then you can . through rest of the files.
Plugin
I have written plugin which simplifies this flow sad.vim which simplifies above to:
siw{new name}<Esc>
And then you can . through rest of the occurrences.
Substitute
Select function body by vi{ and then call:
:'<,'>s/items/{new name}/g
Language Server
If your language has Language Server that supports renames then you can use one of the many LS clients for Vim out there and use the support from there.
The point is: in vim the moviment towards the target change point happens without touching the mouse, and it can also be made via terminal through a ssh session. You should also consider this. I have the following map:
:nnoremap c* *<C-o>cgn
Once you hit the variable just type c* followed by the new name, Esc and dot
Currently, I'm attempting to organize some keyboard shortcuts for IdeaVim v0.48. I've run into a problem when I try to map shortcut "leader + ev" to an Intellij IDE action "ExtractVariable."
There is no official IDE action listed for extracting a variable, strangely enough, so I'm trying to map it to a function key. Here's what I put into my .ideavimrc:
set <F15> = ^[,
map <F15> <leader>ev
where my IDE shortcut for extracting a variable is "Ctrl + Alt + ,"
I've followed multiple guides on this, and still don't understand how to do it. Any ideas?
Answering my own question for others as the IJ Idea documentation is a little unclear:
The IDE action for "Extract Variable" is actually called "IntroduceVariable" if you want to call it from command mode (all other variable extraction actions begin with "Introduce" also). So to map this to a shortcut in IdeaVim, simply put this in your .ideavimrc:
map <what you want to use> :action IntroduceVariable<CR>
I am using SublimeText3 for C++ and Java. I am wondering if there is a way to fold all of the methods in a file / class, and then unfold them all, regardless of where the caret is. Or is there a way to list all the functions / methods.
Basically I would like to be able to enter a file and see all the methods at one quick glance.
Thanks
Using the Sublime Text 3 menu, you can find EDIT -> Code Folding -> which exposes the folding methods and will helpfully tell you the default keyboard shortcuts they are assigned to.
By default you press Ctrl+K, then Ctrl+1 to fold all subroutines. Then, to unfold all I would press Ctrl+K then Ctrl+J.
If this does not work for your file type / syntax, try Ctrl+K, Ctrl+2 and above to see if another folding level works for you.
Unfortunately for me, the proprietary code I work with required custom syntax and a custom function written in our in-house package to fold all of our functions (a new sublime command written in python and installed as a package).
More simple
Select the code and press:
Ctrl + Shift + [ to fold
Ctrl + Shift + ] to unfold
Updates
You can also select an element. Exemple:
Open the console (View -> Console or Ctrl`) with a source code file focused and enter the following commands at the bottom:
view.run_command("fold_all")
view.run_command("unfold_all")
to see their effect.
These commands can be bound with custom key bindings or put into the Command Palette for easy use.
Mac: Go to Edit/Code Folding as image bellow:
Details image
I've just started using Android Studio (IntelliJ), and I now look for the feature to find the occurrence of a string in any of the files in my project. For example: I want to find all the files that contain the string ".getUuid()"
The search at the top right doesn't give me the correct results, and I don't think I can find this feature under Edit > Find.
Could anybody point me at the right direction?
TLDR: ⌃⇧F on MacOS will open "Find in path" dialog.
First of all, this IDEA has a nice "Find Usages" command. It can be found in the context menu, when the cursor is on some field, method, etc.
It's context-aware, and as far as I know, is the best way to find class, method or field usage.
Alternatively, you can use the
Edit > Find > Find in path…
dialog, which allows you to search the whole workspace.
Also in IDEA 13 there is an awesome "Search Everywhere" option, by default called by double Shift. It allows you to search in project, files, classes, settings, and so on.
Also you can search from Project Structure dialog with "Find in Path…". Just call it by right mouse button on concrete directory and the search will be scoped, only inside that directory and it's sub-directory.
Enjoy!
In Android Studio on a Windows, macOS or Linux based machine use shortcut Ctrl + Shift + F to search any string in whole project. It's easy to remember considering Ctrl + F is used to search in the current file. So just press the Shift as well.
Press Shift twice and a Search Everywhere dialog will appear.
Use Ctrl + Shift + F combination for Windows and Linux to search everywhere, it shows preview also.
Use Ctrl + F combination for Windows and Linux to search in current file.
Use Shift + Shift (Double Tap Shift) combination for Windows and Linux to search Project File of Project.
You can open the Find in Path dialog by pressing:
Ctrl + Shift + F
Android Studio 3.3 seems to have changed the shortcut to search for all references (find in path) on macOS.
In order to do that you should use Ctrl + Shift + F now (instead of Command + Shift + F as wrote on the previous answers):
UPDATE
To replace in path just use Ctrl + Shift + R.
Android Studio Version 4.0.1 on Mac combination is for me:
Shift + Control + F
And for all of us who use Eclipse keymaps the shortcut is Ctrl+H. Expect limited options compared to eclipse or you will be disappointed.
In Android Studio on a Windows or Linux based machine use shortcut Ctrl + Shift + R to search and replace any string in the whole project.
What you want to reach is that, I believe:
cmd + O for classes.
cmd + shift + O for files.
cmd + alt + O for symbols. "wonderful shortcut!"
Besides shift + cmd + f for find in path && double shift to search anywhere.
Play with those and you will know what satisfy your need.
use ctrl + shift + f on windows
Press SHIFT 2 times and you can search Every-where , both Class and Method() in the project.
Ctrl + N for finding only Class name.
Ctrl + E for Recent Files.
Use Ctrl + Alt + F combination in Ubuntu.
On a mac use shift + cmmd + f
To get rid of the screen press esc
I use IntelliJ IDEA
version: 2019.2.3 (Community Edition)
Build #IC-192.6817.14, built on September 24, 2019
Runtime version: 11.0.4+10-b304.69 x86_64
In Android 3.6 on a Mac if you want to export the results to a text file then do the following
Command+Shift+F then enter the text you want to search
Then on Bottom Right click on "Open In Find Window"
Then Right Click On Found Occurrences
Then Export To Text File
Once in text file you can find and replace to remove, sort lines etc... please see screenshots for assistance.
I'm beginning to learn VIM (I've downloaded an emulator plugin for my IDE) and unsurprisingly it's making me irritated and extremely slow. That is all fine and I realize it's a phaze everyone goes through.
However this one feature is quite frustrating - being unable to jump to the next line via l, previous with h or search more than one line with f.
Is there a valid, typing speed enhancing reason for this?
You can make h and l wrap lines by adding h and l to the whichwrap option (:he whichwrap), although for the sake of compatibility with scripts and macros that don't expect h and l to wrap, you might want to avoid adding them, and add the < and > options instead (which allow the left and right arrow keys to wrap).
As for f (and F and t and T), they're just really not meant to do that, but you can use / and ? as movements -- d/foo<Enter> to delete everything between here and a following "foo" (whether it's on this line or a later one).