Just installed Eclipse Helios (Win7 64) and I'm having a strange problem. I type syso-Ctrl-Space which is expected to complete to System.out.println("") but it doesn't work! I searched the web for about an hour now, I set Preferences > Java > Editor > Content Assist to defaults, nothing. Everything else seems to work. Ideas?
To be clear: the shortcut works, it completes everything except "syso" as seen so far, on syso (also tried sysout) it says "No Default Proposals". I couldn't find this kind of shortcuts in the Content Assist, but I set them to default anyway.
If you still cant get auto-completion working,try enabling the Template proposals under Content assist menu.This is the exact location,
Windows->Preferences->Java->Editor->Content Assist->Advanced
And make sure you have only one entry for syso(Under Templates menu).
I believe the right template is "sysout" and I believe this can be configured somewhere but could not tell you where. Try sysout and then Ctrl+Space
It's a template, you can find all templates under
Window -> Preferences -> Java -> Editor -> Templates
There you can see that the template name is "sysout" this will then trigger the string substitution for System.out.writeln() but you can change both the template name (if you prefer syso) and/or the actual code produced by invoking the template
Cheers
I am using Eclipse Galileo and had the same problem. Even after trying the above proposed solutions but it didn't work. After making the below change it finally comes out.
Go to Windows->Preferences->Java->Editor->Templates
Select sysout template and edit it.
Change the context from Java statement to Java.
And it worked for me. I hope this will be helpful for you.
As Peter stated, it is under Window -> Java -> editor -> templates.
Look for the line with the following values.
sysout "Java Statements" "Print to standard out" "on"
the preview should be as follows...
System.out.println(${word_selection}${});${cursor}
Your cursor needs to be located in a place where it would be legal to get that line. If your cursor is within a method definition and you type syso you will get the replacement. However if your cursor is in the portion of the text outside of any method definition, say where you declare variables for your class for instance, then syso will not suggest the illegal line system.output.println();.
I had this problem, read all the answers here, became convinced that it MUST be working in my copy, and realized I had been typing syso BELOW the closing } of my last method instead of in the method.
Eclipse on!
You may try to set the shortcut of Content Assist with ALT+L, if it works, then you can choose your favorite shortcut again. (The shortcut Ctrl+Space conflicts with the shortcut of switching input method). In eclipse on linux, the shortcut of Word Completion is ALT+/, so if you set this as the shortcut of Content Assist it also conflicts.)
Just go to the below address:
Windows->Preferences->Java->Editor->Content Assist->Advanced
and click restore default..........that's all
its work like a charm again.
Also check in this eclipse menu:
Windows -> Preferences -> Java -> Appearance -> Type Filters
If you see java.* or javax.* here then try removing it (or Restore Default will do the job) and see that works, it did for me.
Just found the solution for Eclipse Luna: write syso and press CTRL+Space and click on "enable intelligent code completion" and you are set.
I am sure you can find it somewhere in the options as well but this way it is fast and easy!
DIRTY WORKAROUND:
You can try out the following AutoHotkey-Code if you're still struggling like I am (STILL haven't been able to fix it myself)
#persistent
#ifwinactive ahk_class SWT_Window0 ; eclipse java
:*:syso::
sendraw System.out.println()`;
loop, 2
send {left}
return
#ifwinactive
You need to write this in a .ahk file and run it (AutoHotkey needs to be installed). You might wanna put this file into your startup folder. It's a very useful tool, you might wanna expand it one day.
You might have overlapping shortcuts.. Goto 'Overview' than the 'Keys' subsection. Type "ctrl +space" in the 'filter text' section. You should see the "content assist" and probably another command with the same shortcut. If another shortcut does exists, change its shortcut to something else.
Related
I wanted to add a java class to a project, but I did a mistake and added it as a text file. Then, I removed it and tried to add it again as a java class, but unfortunately it doesn't work anymore. And I get the following error:
Unable to parse template "Class" Error message: ABC.java mapped to not java file type text
As I searched, I faced some solutions like
this one but I can't find File Type under Editor or anything similar that I can change as suggested in the solution.
Any help would be appreciated.
PS: I am using IntelliJ 2018.3.4.
Thanks in advance,
Go on File->Settings and a dialog will open. In that dialog navigate on the left part to Editor/File Types and then you need to choose from the section Recognized File Types Java Class and remove from bottom section the problematic extension (note you have a small minus button on the right)
https://www.jetbrains.com/help/idea/creating-and-registering-file-types.html
This is a variant of Markov's answer that worked in my scenario.
Try going to File->Settings->Editor->File Types and to the Recognized File Types tab. Click the "Auto-detect file type by content" choice, and delete the name of the file you are trying to create from the "File Name Patterns" section by using the minus button.
Select required file type in top list (Recognized File Types) -- do it for "Text files"
In bottom list (Registered Patterns) select undesired pattern -- "SomeFileName.java"
Click on "-" (Minus) button to remove pattern from the list
Repeat 1-2-3 for other undesired patterns
If desired, you can also do this manually by editing config file while IDE is closed. Because it's IDE-wide setting, it is not stored in .idea folder (which has project settinsg only) -- the file to look for is called filetypes.xml and shoudl be located in ~/Library/Preferences/IntelliJIdeaXX/options ( see http://devnet.jetbrains.net/docs/DOC-181 for other OS etc )
Certainly inelegant, but you can simply copy the contents of the file to the clipboard (ctrl-c or similar), delete the file (maybe make a temporary backup somewhere outside the project), then in IntelliJ go to the desired package, right click, select new, select Java Class, name it correctly, and then you can paste in the contents of your file (ctrl-v or similar).
The Error is shown when I input anything in the output window
As the name implies, output window is only for displaying output. It seems that you're using VSCode Coderunner extension, which by default runs program in output window.
To change it to terminal, simply put :
"code-runner.runInTerminal": true
In your VSCode User Settings (shortcut: Ctrl + ,).
In general, this problem seems to occur in code runner. But when I was Doing settings according to the upper Most Upvoted Answer, I was not able to edit Json File Correctly as It's showing some error. So, If this is the case, You can do this too.
GO TO VS CODE SETTINGS.
IN USER SEARCH BAR, Type CODE RUNNER TERMINAL
Now, Check the option of Run in Terminal. Voila!! Good To Go!
Solution Image
Type the input in the console, not the output window.
you cant input anything in output window.
if you want make any change or edit in output section you should first do debug in console box and then you can make any change you want
Use the shortcut command Shift + Ctrl + X to bring out the extensions side bar,
Now in the search extensions in market place entry input "#installed code runner",
Make sure you have installed code runner extension (If you haven't do that now),
Next right click on the extension and select extension settings,
Scroll down to run in terminal, finally select the check button.
That should do it.
The output window is only for outputs. Use your terminal for input-based code.
To get output in terminal of vscode :
step1:
Click Ctrl+, or open the settings
step2:
search for code runner
step3:
turn on the Run in terminal checkboxscreenshot is included
I need to disable error highlighting in Java files in VS Code. VS Code tries to check a Groovy file while thinking it is a Java file.
As you can see in the picture all imports after the first and the types after the first field are highlighted red (due to missing semicolons). However I do not want the error check for this Groovy file.
NOTE: I only have the plugins Clang, RedHat.Java, Markdown PDF, Sort Lines, and Uncrustify installed. Even if I disable all the red highlighting is visible.
open your preferences file and add this
"java.validate.enable": false
I didn't try it for java, but it works for typescript.
I found this:
"problems.decorations.enabled": false,
You should disable the linter, which is by default enable in VS Code.
To do so you can go to File-> Prefrences -> setting
I wouldn't think this is necessary but you might try:
"files.associations": {
".groovy": "groovy"
}
in your user settings, assuming your file extension is .groovy. If it is something else, just set it to "groovy" as well. When I create a .groovy file with your content or gibberish I get no error linting at all. What is your file extension and what does Vscode call it in the bottom right of the editor? You can click on that file type to change its file associations. See modifying Vscode file extensions.
I know Eclipse has default keybindings (copy, paste, etc), and you can set keybinds for commands they've already decided on (Generate Setter/Getter, etc) but is it possible to set up a custom command?
For example, I can press Shift+F5 and it'll automatically type or paste "System.out.println();" for me.
In Eclipse Preferences, go to Java->Editor->Templates
Click on "new" to create a new template.
In your template, write in the "pattern" textarea the command you want to be pasted.
For example :
throw new IllegalArgumentException("");
And in the "name" textbox, write the word that matches to that command.
Then, in Eclipse, in your Java Editor, write that word + auto-completion. Eclipse will propose you,among others may be, your template.
The sysout command name is that template :
System.out.println(${word_selection}${});${cursor}
When I edit the java source code, intellij will auto format my code besides the places I edit, how to disable that ?
In the latest IntelliJ Idea (2021.3), Auto formatting can be stopped for one or more file type by going to
Preferences -> Tools -> Actions on save -> Enable or Disable Reformatting action for one or more file type
For those of you who want to disable formatting just for some specific file(s), there is a way since 2018.3 (IDEA-97848).
Go to Settings > Editor > Code Style > Formatter and add your exclusion pattern(s).
I tried disabling trim trailing spaces in code formatting but this doesn't work for my file type '.erb'.
I added my file type '.erb' to selectively disable code inspection for this file type but this doesn't work in IntelliJ version 2016.2.4.
I locked my file after I had made the changes using the lock icon in the Status Bar and this finally worked!
In Preferences > Tools > Actions on save you have a definition
BUT that can be overwritten by the following one, so check in that order:
In Preferences > Editor > Code style > [language] uncheck reformat on file save.
Update: None of those worked for me, so I change my file, commit without save (DON'T save during commit to avoid data loss, you'll be prompted) and then CTRL-Z.
Your file is committed and saved but only with your changes.
FWIW, I'm using Scala, on IntelliJ Community 2021.2, with the Scala plugin.
In my case intellij was messing with all the spaces in the code.
So, I changed following settings :
Editor > General
You can disable IntelliJ IDEA's ability to format (and therefore auto format) specific file types, but it comes at a cost.
To disable :
Settings > Editor > File Types
Select the file type you want to have never formatted
change the extension to something you don't use - for example '*.styl' to '*.oldstyl'
Now, even if you tell IntelliJ to reformat one of these files it won't.
The cost is that you lose syntax highlighting and language support all together.
In my case for stylus files it was worth it.
IDEA kept removing tab characters in sections of code that I wasn't even working in. SUPER annoying and destructive.