how do I bring netbeans default behaviour back? - php

I think I have accidentally overridden one of the default settings in the NetBeans editor (7.2 on Windows 7) and a beautiful feature is gone.
Bracket completion feature is now effected.
I am new to NetBeans. When I used to type
echo "
NetBeans used to place the matching " and put the cursor right after the first quote
echo "|"` // here the `|` denotes the cursor
So when I see the cursor there, I just type... And when I am done typing, I used to be able simply to hit enter (while the cursor is still inside the closing quote) and NetBeans used to automatically put the semi-column at the end of the line (after the closing quote) and advance me to the next line - very nicely. But now, the enter totally creates a new line, pushing the closing quote also to the next line. And obviously, no more semi-column.
So I end up getting this now
echo "test
"
The enter used to give me this instead;
echo "test";
I wonder what went wrong and where. Now I have to hit right arrow to get to the right side of the closing quote and place a semi-column manually and then hit enter.
How do you bring back default settings? What do you do in situations like this?
Running Windows 7 and NetBeans 7.2.1

General answer to your question
The settings are stored in XML files in your user directory:
Example
${userdir}/config/Editors/text/{PROGRAMMING_LANGUAGE_HERE}/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml.
If you delete this file the language settings (including formatting) will be set to default.
I'm not totally sure that feature is in the language setting, but just check the config directory and delete files until that feature is back!
You can also delete specific parts of the XML file to reset only some settings.
Alternative to your specific problem (Alternative 1)
After the discussion in the comments and some search, I found this link as an alternative to your specific request. I'll still leave the original answer there since it answers the question in the title (and to help with future people who use the search function).
Netbeans Tip: Adding a semicolon to the end of a line for PHP
When writing Java in Netbeans there is a handy shortcut that places a semi-colon (;) at the end of the line, simply by pressing ctrl+;. That doesn’t sound like a big deal, but it seems I often write a piece of code yet somehow not have a semi-colon at the end. I think it’s to do with the code complete (eg. The IDE never quite lets me get to the end of the line before I finish writing the code I want to write – it’s a good thing really). However, this feature isn’t available when writing PHP.
Proof of how handy I actually find this shortcut is that I’m now forever trying to do it in Netbeans when writing PHP, only to be left disappointed.
How to do it in Netbeans for PHP
However, there’s a quick way to create this functionality in Netbeans (and any editor that provides macros support):
In Netbeans, click somewhere in the text editor.
Select Edit > Start Macro
Now whilst in the editor, press the ‘end’ key followed by the ‘;’ key. You should now have a semicolon at the end of your line.
Select Edit > Stop Macro
Give your macro a name (eg. “Append ;”)
Click ‘Set Shortcut’
Press “ctrl+;” and click OK
You’re done!
Alternative to your specific problem (Alternative 2)
Also, in Options -> Editor -> Code Templates, you have a bunch of templates, including a eco shortcut which does EXACTLY what you want (double quotes, ;, etc..)! For some reason, those templates won't work for me with the default setting "Expand Template On TAB", but if I change it to CTRL+SPACE, it works perfectly!

Related

PhpStorm background color changed in part of file

I am very new to PhpStorm. I have joined a team and started working on a new feature, but found that part of my file is now without the different colors that are usually shown for PHP. It has a background, which I removed, but the text is plain white (instead of orange, yellow, etc.). I am not sure what I did or how only part of the file is like this and the rest is fine, but any help would be appreciated.
The file is PHP and has some HTML in it. Apart from this one part, everything else has the correct background and the correct coloring.
I tried invalidating the caches and restarting and that helped for a minute or two, but when I switched to something else and then back again, the problem was back. Any help would be much appreciated.
I see 3 main possible reasons:
This file is not treated as PHP by IDE (e.g. associated with just HTML/Plain Text or some another file type). For that I need to see file icon (ideally whole IDE window, just in case).
You have accidentally injected another language somewhere in the file, so that part is now treated as plain text instead of PHP. For that I need to see the screenshot of Settings/Preferences | Editor | Language Injections -- I'm interested in "IDE" in "Project" entries only (for the "Scope" column).
Some plugin interference. For that you would need to provide much more info.
Based on your screenshots, it's definitely wrong Language Injection here. Please delete those 2 injection rules (they do not make any sense to me), it should go back to normal. If unsure: disable them first, check how it goes, if all good -- delete.
You have injected XML language inside the <div> tag ... so no more PHP as it all treated as plain text now (except the HTML tags, since they work similar to XML).

how to insert a unique number inside my php source code file using eclipse IDE?

I need a way to make eclipse IDE suggest a unique number among the current PHP file while I'm coding.
for example if I write somewhere in the code "unique-inCode-Sign-1" and elsewhere "unique-inCode-Sign-2", I need the IDE to suggest for me the next unique number which is "3" , something like this image
I need to do this because when I prepare the file to record and log errors and events that might happen, I need a way to uniquely find an in-code sign that uniquely identify the piece of code that logged the error for later code debugging. I was doing that when I was using notepad++ which suggests the string literals inside his autocomplete functionality. but I can't find a similar feature in eclipse. and obviously I can't depend on my memory to remember the last number specially when I have more than 50 unique in-code signs in the source file.
I'm using eclipse mars for PHP developers

SublimeText 3's PHP syntax behaving like HTML syntax (for comments)

I'm editing a saved .php file in Sublime Text 3 (build 3126 for mac), and when I try to comment something out using cmd+/, Sublime inserts the standard HTML comment
<!-- -->
Sublime does not comment out when I try to use DocBlocks, /* */, # or //.
I've checked and Sublime is currently set to PHP syntax, as it should be. The Build System is set to Automatic. Has anyone ever experienced this and do you know of a fix? I couldn't find this problem anywhere on StackExchange and the only thing I found on Google was:
https://forum.sublimetext.com/t/cant-set-syntax-to-php/7478/8
Since their symptoms don't exactly match mine, I thought I'd ask here before I go as far as clearing caches that I don't know much about.
Maybe this answer is too simple, but it might be your case:
In SublimeText3 when opening comments using Ctrl+/ or Ctrl+Shift+/:
When editing brand-new empty saved .php file, sublime use HTML comments <\!-- -->
But when you open a PHP tag, AND your cursor is inside it, Sublime uses right PHP comments /* */ or //
So it's context sensitive. It uses PHP comments only inside PHP code fragments.
Remember that PHP opening tag is required even in pure PHP-code files.

Eclipse source line error mark doesn't go away after I fixed and saved

I'm using Eclipse for PHP developers v 3.0.2 on MacOS 10.7
This happens very frequently, I'm writing a line of code, eclipse marks an error, I finish the line, the code is correct, I save the file, but the mark remains.
It's not like a cache catches up in a few seconds and then removes the mark, no, the mark remains forever, even after saving.
Some times I delete the whole function, save, then paste the function again and then the mark doesn't appear again.
The code the screen cap shows is correct, there's no brace unbalancing from previous code, before creating the function the code was correct and ran correctly.
If I cut, save and paste the function, it goes away, if just delete the brace, it doesn't.
What could it be?
I know this question is old but for people who have a similar problem my solution was to re-build my project. Right-click->Build Project.
I can suggest something that can slightly reduce the annoyance. This, though not a fix, can remove the cross and ease your mind.
Also, my suggestion is based on experience with the Java Editor and not the PHP one. I imagine the two may behave differently.
There are three ways in which code errors are highlighted by eclipse.
Overview Ruler
Vertical Ruler
Inline (i.e. by a squiggly line in the code)
If you remove one of them, the other two should suffice to tell you that there is an error in the code.
In your snapshot the ugly red cross is Eclipse telling you, via the Vertical Ruler, that there is a problem. To disable this behavior go to Eclipse -> Preferences -> General -> Editors -> Text Editors -> Annotations and uncheck 'Vertical Ruler' like so :
Update
Take a look at this screencast.
Right click and update the project

Using Emacs for Web Development? (Php/mysql/javascript/css/html

I'm a Web developer. I had been using a variety of editors and ide-s for web development(php, javascript,html,css) six months before I decided to learn a true editor and started using emacs. I learned all the basics, used the starter kit, practiced using buffer, windows etc..
I got a grip in 2 months. A month ago I started learning about vim and I found a lot of plugins to achieve the things I want. I'm finding to achieve the same effect in emacs you have to do a lot(for php/js/css/html editing).
Here are the list of things I'm finding hard. Note: These things are related when I'm editing php/html/css/js.
syntax hightlighting(php/smarty). -- the php major mode is too old and it always highlights html/smarty inside the php code incorrectly.
I love ido-mode but i couldn't find how to define a project and fuzzy match files inside the predefined directory
I can setup nerdtree plugin to get a quick overview pane on the left with the files I'm working on with vim. But configuring speedbar and source code browser in emacs is bit difficult.
Context aware completion I really don't know how to do that. I have seen something like that in clojure mode where it shows the definition of a method in the messages area.
Tags-generation: The tags generated with excrebant-ctags does not always work with php. In vim it is easy I can open a file containing the definition right under the cursor.
Manual lookup I want to lookup the manual for a particular word under the cursor without opening the browser (in the messages area(mini-buffer)).
I love ido mode and switching b/w files in tramp,buffers,local files using ido-mode.
Can anyone point me in the right direction? Do you use emacs for same kind of editing I do? What is your work flow?.
nxthml-mode is the ultimate mode for web development.
You can easily define a project in terms of its VCS or .dir-locals.el with find-file-in-project.
Fuzzy matching is called flex matching in ido. You can enable it with:
(setq ido-enable-flex-matching t)
I've never had any problems with ctags, manual lookup is trivial to implement...
Manual lookup I want to lookup the manual for a particular word
under the cursor without opening the browser. (in the messages area
(mini-buffer))
It sounds like you are after eldoc-mode support for PHP? (enable it on a lisp file to see example)
;; Major modes for other languages may use ElDoc by defining an
;; appropriate function as the buffer-local value of
;; `eldoc-documentation-function'.
A search for eldoc-documentation-function and PHP turns up this:
http://www.emacswiki.org/emacs/php-doc.el
I like Emacs for small projects and quick editing.
There are things like C-x ( to make a repeat-macro, delete-matching-lines, describe-function (...), apropos, the quick C-x 2 to split window, the warnings (text was edited elsewhere do you really want...) and the quick Lisp fix in .emacs that make me having an Emacs open at all times.
But for bigger projects, when you want to hover a keyword and have its definition, the call hierarchy, the updated syntax highlighting etc... Emacs is not enough for me. I use Eclipse (which is slow and not perfect anyway for C C++).
syntax hightlighting(php/smarty). -- the php major mode is too old and it always highlights html/smarty inside the php code incorrectly.
The simplest and best way to manage mixed languages in one single buffer is to clone the window showing it with C-x 4 c and use different major modes for each window showing this single buffer, for example, one window with the php-mode, one window with the nxhtml-mode to correctly highlight the HTML syntax.

Categories