Keyboard shortcut for semicolon
이전 댓글 표시
Hi...
Is there any keyboard-shortcut to write semicolon (;) at the last of selected lines?
Like (CTR+R) for putting (%) at the beginning of lines.
I have data with large entry and it requires me long time to do that for every case.
Thanks
댓글 수: 11
Jan
2015년 3월 22일
Please explain, what "data with large entry" is. What exactly is "every case"?
per isakson
2015년 3월 22일
"data with large entry"   Large amounts of data should be stored in special data files and not cause problems in the m-files.
John D'Errico
2015년 3월 22일
AS Per points out, I think the problem is you are trying to enter data by storing it in m-files, to be executed.
You are trying to fix a problem that is caused by use of the wrong tool. Just use data files, that you will then load.
Ismaeel
2015년 3월 23일
Rena Berman
2022년 1월 10일
(Answers Dev) Restored edit
Aryan Ritwajeet Jha
2023년 4월 23일
So, what is the shortcut, if there is any? (I'm not working with large datasets or anything, just don't supress the output initially and then want to supress the output after viewing it once).
Image Analyst
2023년 4월 23일
@Aryan Ritwajeet Jha if you want an output echoed the first time, but not in subsequent times, just do something like this
for k = 1 : whatever
if k == 1
output = GetMyOutput % No semicolon the first time through so it will echo to command window.
else
output = GetMyOutput; % Use a semicolon for subsequent iterations so output will not show up in the command window.
end
end
Compare:
A = [6 6 2;
2 6 9;
2 1 6;
5 5 8;
5 6 1]
B = [6 6 2
2 6 9
2 1 6
5 5 8
5 6 1]
C = {6 6 2;
2 6 9;
2 1 6;
5 5 8;
5 6 1}
D = {6 6 2
2 6 9
2 1 6
5 5 8
5 6 1}
isequal(A,B)
isequal(C,D)
That is, the results is the same with and without the semi-colon
The time that you need the semi-colon is if you are wanting to manually transform a 2D-entry of a data array into a linear entry, such as
F = [6 6 2;2 6 9;2 1 6;5 5 8;5 6 1]
which is getting further and further away from the original request to put a semi-colon at the end of selected lines. If you had a need for something like that, then if the result is going to be less than 10000 characters, the easiest way is take the original 2D array, assign it to a variable (copy and paste it in the command window if you need to) and use mat2str() on the variable, and copy and paste the result. If the result would be more than 10000 characters, then you should probably be seriously questioning whether putting it all into one line is a good idea.
Aryan Ritwajeet Jha
2023년 4월 23일
편집: Aryan Ritwajeet Jha
2023년 4월 23일
Sorry @Image Analyst @Walter Roberson I didn't explain myself clearly and misunderstood the original question. My question is, whether there exists a keyboard shortcut to put a semicolon at the end of a line on which I have my cursor on.
variable = aBitLongerThanUsual____X____LineOfCodeWhichJustHappensToExceedMyScreenCharacterLimit
%I use LiveScript with the Editor on the left and the Outputs to the right.
Imagine that I have my cursor at the X right now and suddendly decide to supress the displayed output for variable.
Currently the only method I know is either naively using the scrollbar to scroll towards the right of the editor window OR put my cursor somewhere on the line and pressing Ctrl+Right, after which I put a ';' at the end.
Image Analyst
2023년 4월 23일
There is no single keystroke shortcut. You can do two keystrokes with "end" and then ";".
Walter Roberson
2023년 4월 23일
If the point is to supress output, then there may be another possibility. In the regular editor at least, if you do not supress output on an assignment, the editor will underline the = with orange. If you move the cursor position to either immediately before or at the = then you then have three choices:
- if you hover for a second an explanation will appear and the right side of that will have a Fix button you can click
- if you right-click before or at the = then a menu will appear, the first option of which is to add the semi-colon
- or when you are positioned before or at the =, press alt-return (⌥ return == option return on Mac). This will insert semi-colon at the end of the expression -- which is where you would want it put rather than end of line, since end of line might be a comment.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!