Word wrap in MATLAB editor

12,134

The way to do this is by using the three dots ... For example:

Hc_frame_1 = uicontrol(gcf, ...
'Style', 'frame',...
'Units', 'pixels',...
'Position', [25 250 200 230]);

These three dots tell MATLAB to continue the command on the next line. Without them MATLAB will think that the command is incomplete.

Share:
12,134
Gnubie
Author by

Gnubie

Updated on June 04, 2022

Comments

  • Gnubie
    Gnubie almost 2 years

    How can I word-wrap long lines of scripts and functions in the MATLAB R2011b Editor?

    I don't mean using Ctrl+J to wrap comments, but show a long line over several lines, each (except the last) the width of the editor frame, as in most text editors, so I don't need to scroll horizontally; the effect is purely visual and it remains as a single line in the file.

    I could not find a setting in any menu, toolbar or the preferences dialog.

    Though I could split the line into multiple lines using "...", I don't want to do this. I want to keep it as one line in the file, just show it wrapped, as in Format > Word Wrap in Windows Notepad.

  • Gnubie
    Gnubie almost 12 years
    Sorry, I don't want to split a logical line physically into different parts. I want to keep it as one line in the script, but just display it in the editor wrapped, similar to Format > Word Wrap in Windows Notepad.
  • Dang Khoa
    Dang Khoa almost 12 years
    @Gnubie - have you stopped to consider why you need this functionality in the first place? If you've got consistently long lines that need wrapping, you should probably be refactoring a little to make those lines less long.
  • Gnubie
    Gnubie almost 12 years
    (1) I've inherited many long scripts, so it's too much trouble fixing long lines. (2) It lets me quickly comment out and uncomment lines using Ctrl-R and Ctrl-T, respectively, during debugging. With blocks, one must select the entire block, making sure no more or fewer lines are selected.
  • Carl Witthoft
    Carl Witthoft almost 9 years
    I want this functionality too, if for no other reason that sometimes I have limited screen space and would like to be able to read code in, say, a 40-char-wide window. hard-wrapping via ... is total bogosity.
  • cladelpino
    cladelpino over 4 years