netbeans read from standard input - netbeans-7

In NetBeans IDE 7.2 in a programme in Java I want to read from standard input. In the past there was a text box at the bottom of the output
Scanner scanner = new Scanner(new BufferedInputStream(System.in));
int i = scanner.nextInt();
thanks in advance
Yiannis P.

Right Click any where in inside the editor and then select Run File and then paste input in output box

Related

How to select a text and put it directly on the search and replace bar of IntelliJ

I'm an IntelliJ user since years and I work on a Mac.
For a long I was able to execute like an automata the following procedure:
select a portion of a text in a file using the mouse
pressing a combination of keys
seeing the selected text in the find & replace bar of the IDE.
Now, I can't remember how to do it.
I have search through the docs of the search & replace in a file, but I cannot see that option.
Just to avoid confusion, the toolbar I'm talking about is the following
I am using IntelliJ on linux (Keymap : Default for xwin) and to select text I use Ctrl+W or Mouse double click. Then ctrl+R will put this text in replace text box
Probably it's a kind of bug. It should work by selecting the text and pressing cmd+r.
Cases when it works:
I select a piece of text in a line and I press cmd+R.
I select the whole line (including white spaces/tabs at the beginning)
Case when does not work:
I select a line from the first character to the last.
More context. I use IntelliJ 2017.2.5 on Mac Os Sierra.

How to remove unnecessary blank line on code formatting in IntelliJ?

Is it possible to remove empty/blank lines using code formatting in Intellij IDEA?
Yes. It is possible to configure the number of blank lines in the settings menu (CTRL+ATL+S): File -> Settings -> Editor -> Code Style -> Java(or Scala or whatever your language is) -> Blank Lines
File >> Setting >> Editor >> Code style java >>Blank lines tab
You should change to 0 in code label(as picture), It would remove all unnecessary blank line when press format shortcut: ctrl + alt + L
You can find and replace with regex option also ^(?:[\t ]*(?:\r?\n|\r))+. It searches all empty lines in file. You need to just replace it with empty
I use regular expressions to remove extra blank lines from the code. Here are the instructions.
Open Find and Replace dialog. Use shortcut CTRL+SHIFT+R.
In the search box type ^(?:[\t ]*(?:\r?\n|\r)){2,}. This will search for two ore more blank lines.
In a replace box type \n. This will replace with one blank line.
Open Reformat Code dialog and click Run. Use shortcut CTRL+ALT+L.
This works on all JetBrains IDEs. Use the screenshot as referece.
Just in case it helps someone using newer versions of Intellij, in Intellij IDEA 2016.2.4 it is File -> Other Settings -> Default Settings -> Editor -> Code Style -> Java(or Scala or whatever your language is) -> Blank Lines
For those trying to remove blank lines at the end of the file, this became a feature as of August 2020.
The proper place to configure this action is under Settings|Editor|General|On Save. Check "Remove trailing blank lines"

How to have the formatter wrap code with IntelliJ?

I'm not able to format my code in IntelliJ.
I can see the margin line (by default at 120 columns) but it seems that the activation from the menu:
Code -> Reformat Code
is just ignoring this margin.
IntelliJ IDEA 14, 15, 2016 & 2017
Format existing code
Ensure right margin is not exceeded
File > Settings > Editor > Code Style > Java > Wrapping and Braces > Ensure right margin is not exceeded
Reformat code
Code > Reformat code...
or press Ctrl + Alt + L
If you have something like this:
thisLineIsVeryLongAndWillBeChanged(); // comment
it will be converted to
thisLineIsVeryLongAndWillBeChanged();
// comment
instead of
// comment
thisLineIsVeryLongAndWillBeChanged();
This is why I select pieces of code before reformatting if the code looks like in the previous example.
Wrap when typing reaches right margin
IntelliJ IDEA 14: File > Settings > Editor > Code Style > Wrap when typing reaches right margin
IntelliJ IDEA 15, 2016 & 2017: File > Settings > Editor > Code Style > Wrap on typing
Do you mean that the formatter does not break long lines?
Then please check:
Settings / Project Settings / Code Style / Wrapping
Update:
In later versions of IntelliJ, the option can be found under:
Settings / Editor / Code Style
There select Wrap when typing reaches right margin.
Enabling "Ensure right margin is not exceeded" doesn't work for me in Intellij IDEA 2018.2. I have found the workaround, we need to change every elements below from "Do not wrap" to "Wrap if long".
After that, we can preview what kind of wrap type will be changed by looking into right panel. If we are satisfied, Click "OK" or "Apply" to apply the changes. Finally we need a mannual format by using CTRL+ ALT+ L in Windows and Command+ Shift+ L in MacOS.
Or you can use the shortcut:
Ctrl + Alt + L
In order to wrap text in the code editor in IntelliJ IDEA 2020.1 community follow these steps:
Ctrl + Shift + "A" OR Help -> Find Action
Enter: "wrap" into the text box
Toggle: View | Active Editor Soft-Wrap "ON"
In the latest IntelliJ, version 2020, we have an option called soft-wrap these files:
Settings > Editor > General > soft-wrap these files.
Check this option and add the type of files you would like to apply the wrapping to.
Related question on JetBrains' IDEs Support Forum: Wrap code to indent
You can create a macro for Ctrl +Shift + S (for example) that do all this things:
Edit > Macros > Start Macro Recording (the recording will start). Click where you need.
For example:
Code > Reformat Code
Code > Auto-Indent Lines
Code > Optimize Imports
Code > Rearrange Code
File > Save All
... (all that you want)
Then, click on red button in bottom-right of the IDE to stop the Macro recording.
Set a macro name.
Go to File > Settings > Macros > YOUR MACRO NAME.
Right Click > Add Keyboard Shortcut, and type Ctrl + Shift + S.

Intellij New line on current line shortcut

Is there a keyboard shortcut to start a new line on the currently selected line?
I.e. The current line goes down one line and the cursor is on a blank line.
There is Shift + Enter which starts a new line but on the next line. I want the current line.
CTRL+ALT+ENTER was the right shortcut for me (version 12.1.6).
CTRL+SHIFT+ENTER works as of 11.2.
On mac this works for me:
⌘+ ⌥ + ↵
There isn't one, but you can very easily create it using a macro.
In order to create the macro you can follow these steps:
Place the cursor on any line with code.
Click on menu Tools | Start Macro Recording
Press: Home -> Enter -> Up
Click on menu Tools | Stop Macro Recording
Test your macro using Tools | Playback Last Macro
You can remove any action from the macro that doesn't belong there by using Tools | Edit Macros.
When the macro is working fine you can assign a shortcut to it in the Settings window on the Keymap page.
Do not think anything exists in version IntelliJ 8 or 9 for that matter. Prove me wrong.

Testing Copying/Pasting with RobotFramework

I create some custom copying functionality for my web application that I want to test. I can't find any Keywords for copying or pasting in the documentation though. Does anything like this exist?
You can use the following code for copy paste in Robot Framework
1.Install clipboard library using command in CMD : pip install clipboard
2.use code:
Copy To Clipboard ${TextToCopy}
Click Element ${TargetLocator}
Press Key ${TargetLocator} \\22
You can use Selenium2Library that has a keyword name Press Key then we could get the values from ascii table such as ASCII Table
We can see that ctrl+A hex value is 01 - we need to hit that to highlight the text.
You could try something like this
Copy Text and Paste Text
[Documentation]
... CTRL-A -> 1
... Copy-> 03
... Paste -> 16
Press Key ${seleniumLocator} \1 #Highlight the text Ctrl+ A
Press Key ${seleniumLocator} \03 #Copy Text Ctrl + c
Press Key ${Some_Other_Locator} \16 # Paste Text Ctrl+ v
For copying and pasting using Selenium + python (using keyboard shortcuts):
Performing-a-copy-and-paste-with-selenium-2
You can also create a method to re-use (e.g. using RobotFramework):
Paste command using Selenium
You will need to first import the selenium2 library for RobotFramework.
I have been using RFW for a while now. I've never heard of copy/paste as you mentioned.
Thus, the only way would be custom your own keywords based on python libraries.
You can use the OS library of Robot Framework
http://robotframework.org/robotframework/latest/libraries/OperatingSystem.html#Copy%20File