Netbeans IDE has code format feature that can be launched using the "Format" item in the "Source" menu. how can I customize this "Format" operation so my formatted code will be in the style that I define. I could not find any special documentation in Netbeans Help or online WIKI.
Tools-Options-Editor-Formatting-(Language:PHP)
Don't forget to configure all categories (Not Tabs and Indents only)
I think right now this is our best bet http://www.netbeans.org/issues/show_bug.cgi?id=163030
Related
I am used to double-click to select a word. I am addicted to using double-click to select a word. Almost everywhere it is there - eg, notepad,Gnome-edit, ...
Would please someone help me how do I set this functionality ?
What do you mean by "set"? It works "out of the box", no need to setup anything
It seems a bug of a specific NetBeans editor module, not an option you can set. For example, in NetBeans 7.4 the selection works all right (selecting the whole word) for PHP and JS files I'm working with, but not all right only for TPL files (HTML/JS/Smarty variables and values in TPL files), which are managed by the Smarty Framework plugin.
How can do code alignment with Eclipse base Force.com IDE.
Alignment shortcut key 'CTRL+SHIFT+F' is not working for Apex code.
None of the suggestions so far work for me. Note that the Force IDE opens the Apex class in an Apex Editor. This editor does not appear in the list of contexts that you can associate with a key event. For example, this list contains such contexts as "editing in structured text", "editing in Java Source", etc.
The Apex Editor does not contribute a "Source" menu option to the right click menu. So there is no way to get to the formatting features.
I tried to open the apex class in the Java. Now the "Source" menu option appears the format option doesn't do anything. (Hence no key event will be able to do anything.)
The only thing I can get to work is this ...
Select file.... Open With... Other ... locate Java Editor.
Once file is open ... select all text .. right click and select Source ... Correct Indentation .
This does not reformat but it does fix the indentation problem.
Someday I hope SFDC will make the code for the Force IDE open source. Then we, as a community, could build more developer-friendly tools.
Apex classes and triggers use a different editor than Java. The auto formatter (or code alignment) does not work with Apex Code (or the Apex Code Editor). I couldn't get CTRL-SHIFT+F to work in the most recent version of Eclipse with the Force.com IDE, either. I believe this is because the auto formatter is designed to work with Java only.
However, if you switch to the Java perspective and open your Apex class with the Java Editor, CTRL+I does correct indentation properly.
Go to Preferences -> General -> Keys and type "format" into the search box, you will see what keys (if any) are bound to the format commands. Then you can bind what you like or use what's available.
I have a file with extension .xml.
But it doesn't necessarily contain XML. It may also contain HTML and JavaScript. Now I would like to either have Eclipse decide inteligently/heuristically which syntax highlighting would be appropriate or to switch it myself.
Any ideas?
Eclipse associates files with an editor. You can let eclipse decide which editor to use (e.g. defaults per file extension) or select the editor by yourself. I guess you might already know that or have at least experienced it.
Syntax highlighting isn't always set seperately but instead part of some editor (together with stuff like keyboard shortcuts). So what you are going to need is an editor that behaves the way you want it to. I do not know if there is an editor like this available but one options is writing an eclipse plug-in and implementing such an editor.
Fortunately there are great editors for each of XML, javascript, HTML, etc that are all open source. I guess you might be able to use some of their code. Ideally as a client of their API / Objects or if it won't work out just by reusing code.
short answer: not possible. use PHPStorm instead :)
Can some one suggest me a plugin to format HTML and JAVA code with proper indents etc ? Is there any built in option there in Eclipse ?
Use Source -> Format or CTRL+SHIFT+F
Eclipse does have built in Java formatting:
Preferences > Java > Code Style > Formatter
For HTML, you might try something like HTML Tidy. The Web Tools Platform project also includes formatting.
It's a combination of all the answers above, which suits me-
Go to Preferences > Java > Code Style > Formatter and set all the options you want by creating your own profile or using a default one. Personally I find the line-wrap limited to 80 a little too low. I set it to 200.
Save the 'custom' preferences by giving it a new profile name (export it for future restoration)
Select the code in your editor - then hit CTRL+SHIFT+F. That should format your code.
Worked wonders for me everytime.
Java code formatting is built in. Go to Window->Preferences->Java->Code Style->Formatter. There's a built in profile set up and you can make your own.
http://sourceforge.net/projects/jalopy/
Note that Jalopy has its settings under Window> Jalopy Preferences.
(This menu option appears only when all editor tabs are closed)
Eclipse doesn't have proper built-in code formatting. You might want to open your project in Idea IntelliJ or Netbeans and use their formatting to do a thorough job on it.
I'm a recent semi-convert to Eclipse after 20 years of using vi and gvim. One of the things I miss about gvim is that I could cut a bunch of different snippets of code into named buffers, and paste them at will when doing something like repeating a common idiom. For instance I'd have it so "ap would paste
DatabaseHandle handle = null;
try
{
handle = DatabaseConnectionPool.newHandle();
and then "bp would paste
handle.commit();
}
finally
{
handle.rollback();
DatabaseConnectionPool.returnHandle(handle);
}
And I could repeat both of them over and over in the course of a day. In an answer to another question, somebody mentioned that you could "manage code snippets" in Eclipse, but didn't mention how. So now I'm asking: how do you manage code snippets in Eclipse?
You might want to store those two snippets into a code template, as explained in this tutorial.
And do not forget about the possibility to quickly execute any kind of java code snippets in a scrapbook (not exactly what you want, but it can come in handy at times)
Newtopian adds (in the comments)
In fact templates become much more powerful by adding variables and tabstops within, so your example above would become dbHandle ctrl+space. It would copy snippets from both parts and place your cursor right in the middle.
Eclipse also offers something very similar to the templates feature described by VonC called (would you believe) snippets. Window > Show view > Snippets.
To add a new snippet category: Right click in the Snippets window and click Customize...
Click New > New Category. Enter a category name if necessary (e.g. "Java"). Click Apply.
With your chosen category selected, click New > New Item. Enter your snippet.
To use a snippet, put the cursor where you want to insert the snippet, then double click on a snippet in the Snippets window.
I ran into the Snip2Code plugin recently.
It did the job, and I can collect and search snippets in a quick way.
Well a picture worths a thousand words, what about this one?
The question is old but the link of the answere is older ;)
Here is a nice tutorial:
http://www.dansshorts.com/post/creating-snippets-in-eclipse
I have used snippets in some IDEs, like Dreamweaver and Homesite, an old Coldfusion IDE. I also use a lot of snippets in MySQL Workbench - where i type a lot of SQL, very handy there.
I am now using Eclipse Java EE IDE for Web Developers Version Indigo Release and found the snippets panel in Window|Show View|Other...|General|Snippets. I was able to manipulate it and figure out how to add the code I wanted as snippets and how to use it efficiently.
Use Eclipse Snipmatch (Part of Eclipse for Java Developers Package).
Works very well for Java code snippets but also works for any other language like HTML, ABABP, PHP etc.
You can convert any code fragment from your editor directly to a code template. Highlight the code you'd like to convert to a snippet, context menu "create snippet", complete the form and done.
snippets can be shared via Git repositories with your team members
Manual:
https://www.eclipse.org/recommenders/manual/#snipmatch
Installation:
https://marketplace.eclipse.org/content/snipmatch