I am using java on Intellij and I wonder if it is possible to make it so that it automatically places quotations System.out.println(here);
Thanks
Yes, it is possible.But a bit tedious. (EDITED)
ECLIPSE
you need to know that Ctrl+space opens options for autofill.
you need to create a simple template at
Window>Preferences>Java(dropping menu)>Editor>Templates>New...
In the open window at Name type: Syso
at Pattern: System.out.println("")
Make sure the checkbox Automatically insert is on.
Apply and close
Now every time you type Syso and hit Ctrl+Space there will be first option
of autofill with quotations. Profit.
oof, didn't notice about Intellij , my bad. Thought about Eclipse. Well here is one for Intellij
INTELLIJ
I believe the Intellij version of cntl+space is Tab button
Go to Settings>Editor>Live Templates
Pick any template and press Plus icon. Choose Live Template
In abbreviation type your desired word (I would put: Syso)
In Template txt type : System.out.println("")
Make sure the box with Reformat according to style is checked
Now every time you type Syso you can hit Enter and have PROFIT!
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed last month.
Improve this question
How can I search and replace a String in all files of my current project?
Let's say I have the string "/sites/default/" now I want it to be "/public/sites/default/", but there are almost 1000 files.
Goto "Search"->"File" from menubar at the top left
Enter text, file pattern and projects
Click "Replace..." button at the bottom
Enter new text click ok
Voilà...
Depending on the file type you are focused on, Ctrl+H will open up different types of search screens.
A more consistent hotkey would be using the Alt method: Tap Alt, then A, then F.
Efficient Order of Operations:
Ctrl+C the text you want to do the replacing (if available)
Highlight the text you want to be replaced
Tap ALT, then A, then F. Brings you to File Search. The selection from (2) will auto-fill the search box
In the “File name patterns” input box, type in “.java” for replacing all Java files or type in "" to replace in all files
Click “Replace…”
Ctrl+V (Paste). Or type in the value you want to do the replacing
Enter
You can find more details in my blog post: http://blog.simplyadvanced.net/android-how-to-findreplace-in-multiple-files-using-eclipse/
Use Ctrl+H for opening Eclipse search dialog, select appropriate search tab and select "Replace..." to get you to the "Search and replace" dialog
Strange but it is a two step task:
Search what you want
In the search tab right click and select replace , or replace all:
A demo at:
http://www.avajava.com/tutorials/lessons/how-do-i-do-a-find-and-replace-in-multiple-files-in-eclipse.html
Tonny Madsen said it right, but sometimes this is too simplistic.
What if you want to be more selective in your replacements since not all replacements are correct for what you're trying to do?
Here's how to get more granularity to do the replacements only in certain folders, files, or instances:
First, do like he said:
Click Search --> File... OR press Ctrl + H and choose the "File Search" tab.
Enter text, file pattern and choose your Workspace or Working Set.
Then:
Click Search
When your results come up, make some folder, file, or instance selections by Ctrl + clicking on the ones you'd like to select. Ex: here's my selection. I've chosen 3 instances, 1 file, and 1 folder:
Now, right-click on your selection and go to --> Replace Selected.... Here's a screenshot of that:
Enter what you'd like to replace it "With". In my case you can see it says it is "Replacing 190 matches in 4 files". Now click OK.
Voilà!
References:
Here's the tutorial I came across that taught me this: http://www.avajava.com/tutorials/lessons/how-do-i-do-a-find-and-replace-in-multiple-files-in-eclipse.html?page=2
ctrl + H will show the option to replace in the bottom .
Once you click on replace it will show as below
There is an option in search => file and shortcut is Ctrl+H. Go for further refer follow link. This is work fine with Eclipse Neon
Is there a way to find/replace across an entire project in Eclipse?
If you want to replace two lines of code with one line, then this does not work. It works in notepad++. I end up open all files in notepad++ and replaced all.
Ctrl+F gives me Find/Replace dialog box.
Or you can,
First Alt+A
Next Alt+F
Then press on Replace button.
If non of them worked:
Goto -> Window -> Preferences -> General -> Keys and search for replace then you will see binding for Find and replace. In the bottom of that window, you can add your key to Binding text box. There you can add or edit any keys as shortcut.
I have tried the following option in Helios Version of Eclipse.
Simply press CTRL+F you will get the "Find/Replace" Window on your screen
I want to have shortcut commands in sublime text 2.
I want to simply type sopl and press tab to generate System.out.println('text'); with the word 'text' selected and ready for me to replace it.
I want to simply type sop and press tab to generate System.out.print('text'); with the word 'text' selected and ready for me to replace it.
I have installed SublimeJava plugin but apparently there is no such short cut
You're looking for pl<tab> for System.out.println(|); and p<tab> for System.out.print(|);. It doesn't put the 'text', but it does put your cursor in the right place to type. Also note that, like Eclipse or IntelliJ, when you expand a Snippet, Tab will continue to move you through the positions in the Snippet until you've filled in all the blanks.
These are called "Snippets", and you can find them under Tools -> Snippets.... You can add new ones with Tools -> New Snippet....
it is very simple, just go to Tools>Developer>New Snippet.. remove all the code there and copy paste the below code...
<snippet>
<content><![CDATA[System.out.println("${1:text}");]]></content>
<tabTrigger>sysout</tabTrigger>
<scope>source.java</scope>
</snippet>
now press ctrl+s and give some name (make sure that you're saving file with .sublime-snippet extension) and click on save.
now open any .java file and type sysout and press tab that is it...
you can also refer this article for more info..
I have defined an Exit command to display on my File menu. However another plug-in is contributing a Open File item on the File menu and this is appearing AFTER my Exit command. I want my Exit command to appear last on the File menu.
I've tried specifying locationURI menu:file?after=org.eclipse.ui.openLocalFile but then my Exit menu item does not display at all. I think this might be because org.eclipse.ui.openLocalFile has not been loaded yet.
I've also tried specifying locationURI menu:file?after=additions but the Open File menu item still displays after mine.
How can I get the menu item order to be Open File and then my Exit command?
You need to put some of the proper group markers in your File menu when you create it. The order of operations is:
ActionBarAdvisor creates
MenuManagers programatically
org.eclipse.ui.menus are applied
legacy action extensions are applied
(like actionSets)
Open File says it has a menubarPath="file/new.ext". So however you create your File menu, you must add a group marker for new.ext. The group markers will allow you to control the contribution order.
See org.eclipse.ui.internal.ide.WorkbenchActionBuilder in org.eclipse.ui.ide for an example of the group markers the eclipse IDE includes.
I know that this question has been answered but I had similar problem and I solved it by specifing the ID for each command that I add to menu. Then I would use that ID in "after" or "before" query. I noticed that you tried something similar but you used the "commandId" instead of the actuall "id".
Anyone know the keyboard shortcut to copy/paste a line into a new line in Eclipse, without having to highlight the entire line?
ctrl-alt-down turns my whole screen upside down (I'm on windows). Interestingly, that's what's specified in the windows->preferences.
Ctrl-Alt-Down: copies current line or selected lines to below
Ctrl-Alt-Up:: copies current line or selected lines to above
Ctrl-Shift-L: brings up a List of shortcut keys
See Windows/Preference->General->Keys.
(Tested on Windows) [Per below comments, works as well in Ubuntu, IBM RTC 4 / RSA 9]
In Eclipse, press Ctrl+Shift+L two
times in succession (or Ctrl + 3 > type: Keys > Enter).
In 'type filter text' (search) text box, type Copy Lines
Select the filtered row, right click the 'Binding' field, and do Select All
Press Ctrl+Shift+V
Give OK
From now on, for any line you want to duplicate, just press Ctrl+Shift+V.
You have to turn off the graphics hot keys that flip the screen. If you're on Windows, you need to right click on the Windows desktop and select "Graphics Properties..." (or something similar depending on your version of Windows). This will bring up a screen where you can manage graphics and display options, look for a place where you can disable hot keys, sometimes it's hidden under something like "Options and Support". Turn off the CTRL + ALT + ↑ and CTRL + ALT + ↓ hotkeys (alternatively you can just disable all graphics hot keys if you're not using them).
If you want to copy a line to the clipboard you can also use the trick:
Ctrl-Alt-Down
followed by
Ctrl-X
The drawback is that the file where you copy the line from becomes dirty.
Ctrl-D would delete a line
Ctrl-Z would undo deletion, with highlithing entire line
Ctrl-X/C cut or copy entire line
The advantage over Ctrl-Alt-Down followed by Ctrl-X suggested by other users is that it doesn't make eclipse think that the file was changed in any way. It's also faster and causes no problems even if the user has rotating screen issue with Ctrl-Alt-Down/Up keyboard shorcut. So there's no need to remap shorcuts for this.
Another way to go would be hitting Alt-Shift-Up until the entire line gets selected. If you've gone too far, of course you can select less with Alt-Shift-Down.
If Your Window pc, you may try this, it's also for STS:
Ctrl + win + Alt + Down :: Copy current line or selected line to below
Ctrl + win + Alt + Up :: Copy current line or selected line to above
I've written the linecopypaste plugin for Eclipse that mimics Visual Studio's copy/cut/paste behaviour. I've also found copycutcurrentline which appears to do the same.
On my Mac the default setting is is ALT+CMD+Down
You can change/view all key bindings by going Eclipse -> Preferences (shortcut CMD+,) and then General -> Keys
Ctrl+Alt+Down Copies current line to below like notepad++ (Ctrl+D)
If your whole screen is 180° rotted then you should disable your hotkey settings.
Right Click -> Graphics Options -> Hot Keys -> Disable
That it now you done try shortcut Ctrl+Alt+Down
Try this in MAC.
ALT + COMMAND + DOWN
it works.
If anyone using Mac computer the CTRL + ALT + DOWN keys doesn't work.
Try it with,
ALT + COMMAND + DOWN
It works.
We can assign any command to any action(given) in Eclipse
From Menu Bar go to
Window > Preferences
then search for the keys
then search copy line
then click on copy line and then click on command in Binding
and peform a command which you wish to use for duplicating line i use ctrl+shift+d
you can choose whatever you want
On Mac, I've tried the linecopypaste and it works great
cmd+c -> Copy current (unselected) line, just like "yy" command in Vi/Vim
cmd+v -> Paste it, like "p" command in Vi/Vim
Thank's Larsch for your work!
PD: Using Eclipse Luna 4.4.2 in Yosemite
I have to change the assigned key,
e.g.
Windows/Preference --> General --> Keys
Select "Duplicate Lines" under command
Click on "Binding"
Ctrl + Shift + D
Just another approach:
1) Alt+Up and Alt+Down (or Alt+Down and Alt+Up, order does not matter)
2) Ctrl+C
But of course vim's "yy" is the fastest :)
Disabling the hot keys for the Intel Driver worked for me for Windows 7. However, for Windows 8, when I tried that, it prevented eclipse from getting the Ctrl-Alt-Down keystoke. I had to change the Intel driver key binding to Ctrl-Alt-F10 (or something else it will accept). Eclipse then gets the Ctrl-Alt-Down and copies the line.
For mac, shift+alt+down_arrow works in netbeans' editor.
It's working with me on ,
Eclipse + Spring tool suite .
ALT + COMMAND + DOWN
I am using Windows 7. To disable that all I did is to Right click on the Windows desktop and select "Graphics Properties" ->Options. Then selected "Off" at the left side on the resulting screen. This disabled all hotkey combination. I think there is no way to disable only some them, its all or none. Anyway I didn't need them. So now crtl+Alt+Up and Crtl+Alt+down works for me in Eclipse and my screen stays same :)
I think similar option also exist in other versions of Windows. Have fun :)
For personal usage, I add a vim plugin like Vrapper to Eclipse and just use yy to copy entire line.
The Ctrl+Alt+Down / Ctrl+Alt+Up flips my screen so I overrode that in the Eclipse shortcuts via
Window => Preferences => General => Keys.
Search for "dupl" to find the Duplicate Lines command. I overrode the default and chose Ctrl+Shift+D. For me, that's easy to remember just like Ctrl+D to delete lines
ctrl+alt+down/up/left/right takes precedence over eclipse settings as hot keys. As an alternative, I try different approach.
Step 1: Triple click the line you want to copy & press `Ctrl`-`C`(This will
select & copy that entire line along with the `new line`).
Step 2: Put your cursor at the starting of the line where you want to to paste
your copied line & press `Ctrl`-`V`.(This will paste that entire line & will
push previous existing line to the new line, which we wanted in the first place).
The combination of Ctrl + Shift + Alt + Down worked for me on Linux.
To copy text from the begining of line to the cursor position: ctrl + insert
It does the job and save a lot of time for me.
Another shortcut way to do this is press Ctrl+Shift+L and select which command you want to perform and hit enter
its best practice for beginner.
See how to make the eclipse default shortcut work ctrl alt↓
Select line: Put cursor on the line to copy, select line with ShiftHome if cursor in the end of line or ShiftEnd if cursor is in starting of line
Duplicate line below (default expected behavior) or above ctrl alt↓ or ctrl alt ↑ but the key here is you need to select the line/block
Some answers focus on disabling the screen Rotation in Windows or any other OS, that applies to prevent accidental keypress.