Matlab Editor - show tabs and whitespace characters - matlab

I've been writing a lot of code in Matlab 2012a recently, and I'm wondering if there's some way to show whitespace characters (tabs, spaces, etc.) like in Notepad++ or Sublime Text.
I've been Googling around and did a search on SO, but the internet seems oddly quiet.
Thanks!

Although I don't think you can do this in the MATLAB editor, you can choose to use a different editor as your default. Under Preferences go to Editor/Debugger, and select "Text Editor" rather than "MATLAB Editor" (you need to supply the full path).
If this is set, then .m files etc. opened from within MATLAB should open in your preferred editor, not the MATLAB editor.

Related

Marking/commenting Matlab code?

Is there any way to mark Matlab code (in Matlab) via some kind of add-on? I'm looking for something similar to what Microsoft Word has with its "Review" mode where you can highlight a certain phrase/section and make a comment on the side. When I say "comment", I don't mean the regular code comments that you do with "%" in Matab.
I've googled for this, but I couldn't find anything. Anyone know if something like this exists that I may have missed? It would really help me when I'm reading someone else's code and I have to keep track of things / make comments for certain lines. Even if commenting isn't possible, it would be nice to be able to highlight certain lines via some kind of "highlighter" like the one in Word.
No. This isn't possible.
In fact, most editors and IDEs (if not ALL of them) that I know don't even support this feature as each IDE will have to be specific in the way this is implemented (à la Trojanian). The only thing that I can think of is if you print out the code in PDF, then use bubbles within the PDF viewer to tack on your comments.
However, if you want to highlight a specific line in your editor, you'll have to set this up in your settings. Go to preferences, then in the Editor / Debugger options, choose the Display option, then choose Highlight Current Line. Choose whichever colour you see fit. I'm running MATLAB R2013a on Mac OS, and this is the window I get:
You'll see the Highlight Current Line feature. Change that to whichever colour you want. I have it as gray because I do like having the current line highlighted.

Can I use MATLAB editor without running MATLAB?

Is there any way to open MATLAB editor without opening MATLAB ? I would like to edit my codes using MATLAB editor and my laptop is getting very slow. So Can I just open MATLAB editor?
Also, is there any good editor like MATLAB's editor?
The MATLAB Editor is part of the IDE, so you can't launch it without launching MATLAB.
Notepad++ is a great text editor for Windows, that supports syntax highlighting for many languages, including MATLAB, and is pretty lightweight.
You can just open it in notepad or text editor. Just right click on it and select open with and then select whichever text editor you want to use.
Since MATLAB GUI is quite computationally expensive I open MATLAB without the GUI:
matlab -nodesktop
In such a way I have the MATLAB prompt ready to work and I edit files with sublime text editor setting MATLAB syntax.
It looks like this:

Eclipse indents new line with tabs instead of spaces

I've followed all the suggestions here.
When I press return, I get a new line that is indented with tabs instead of spaces.
If I backspace to clear the tabs, and then press TAB a series of times, it correctly indents with spaces.
I'm pretty sure I have all my settings set up correctly. I created a new Code Style > Formatter policy for every language in the project, and specified to always use spaces. It seems as though these settings are partially active (ex: when I press tab), but inactive when I use return. I tried restarting Eclipse. I'll try restarting the computer now...
I'm using Mac OS X 10.9.2 and a Liferay Developer Studio (1.6.3.v201312111844) version of Eclipse (not sure which Eclipse build its based on though).
Can anyone think of another setting/solution to ensure that newlines are created with spaces instead of tabs? I recently saw http://editorconfig.org/, and I'm wondering if there's some interference.
Thanks for any suggestions
If the file has existing lines that are using tabs, then Enter will respect that and try to create new lines in a similar way (see this comment by topchef for a solution). Also, it could be something in Liferay Studio's proprietary settings is overriding Eclipse standard preferences (as suggested by user John).
Keep in mind that each type of editor in Eclipse can have its own preferences and perhaps that's what you're running into here. You can try to find them all by opening Preferences and searching for "indent" in the search field. That will show all the preferences pages where indentation can be configured.
Also note that the Formatter settings don't have any affect on as-you-type formatting; that's for when you select a file or group of files or part of a file and choose Source > Format from the menu.

How do I specify my whitespace style in Eclipse and reformat an offending document?

I have a document that is mixed HTML, JavaScript, and PHP. I edit it in Eclipse.
I am not the original author of the document, I am modifying it.
When modifying it, Eclipse's TAB and SHIFT+TAB (Indent and Unindent) do not function as expected.
Any indentation I insert by pressing TAB can be undone with SHIFT+TAB, but the indentation already in the document cannot be undone the same way. Pressing SHIFT+TAB in this case does nothing.
It seems the whitespacing in this file is different than what Eclipse expects.
My natural coding style (which came from customizing VIM) is spaces-only, with my TAB and SHIFT+TAB inserting and removing four spaces at a time.
How do I reprogram Eclipse for this, and then get Eclipse to restyle this document of unknown formatting to restore my keyboard shortcuts to normal behavior?
I understand that [Window] -> [Preferences] -> (language) -> [Code Style] contains a lot of options, but that's more than I was looking to do right now, plus I commonly find myself working in a lot of different Eclipse installations. Are there predefined Code Styles I can find somewhere for this particular style and import? I would imagine it is a relatively common style.
As far as I know there is no way no import a particular set of preferences, which seems what you are looking for. You import and export them as a whole (and it doesn't work very well, by the way).
I am afraid what you have to do is to configure them yourself in the preferences and edit the code more or less manually.

Is there a way to copy code from the Eclipse IDE without the rich-text formatting?

Recently every time I copy a block of code from Eclipse and paste the code into TextEdit or a online forum using the code tags, I get the code with the rich-text or html formatting, so I have to copy into a text editor remove the formatting copying and pasting again, In the past this was not a problem I used to copy from eclipse and paste the code without any formatting at all just as plain-text, I dont know if I turn on a property or what I did for this to happen, any ideas how to fix this?
There is an Eclipse bug filed for this that can be voted for:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=45969
It has been open for 10 years though!
There are applications out there that think they can handle rich text but can't. So for those it looks like we'll have to carry on with "Copy-Switch to Notepad-Paste-Select All-Copy-Switch to final app-Paste" for some time yet.
Note: the rich formatting from a SWT editor seems to have always been available (bug 64498).
You could use "Edit, Paste and Match Style" in TextEdit.
From the Edit menu, choose Paste and Match Style,
or use the keyboard shortcut, Shift Option Command V.
The pasted text will pick up all the formatting from the character to the left of the flashing insertion point. This technique works in Mail as well.