MATLAB Community

MATLAB, community & more

Two editor shortcuts I bet you didn’t know about

The MATLAB Editor has plenty of handy text-editing actions built in to it. Unfortunately we don’t have a concise way of advertising or providing default keyboard shortcuts for all them. Amongst the standard cut/copy/paste-style actions that we are all familiar with, the Editor also has two forward-deleting actions.

The first is “Remove Next Word” (Ctrl+Delete default on Windows). This does almost exactly what you’d think. Starting at the caret (or, text insertion point) all text up to the next letter after a space is deleted. So if you’re at the end of the word, the space is deleted. If you’re in the middle of a word the rest of the word and following space is deleted. Basically, this sticks the next word to the right of where you are. Used in the standard way, repeated invocations go through your line (and on to the next) deleting one word at a time. This is useful when you find yourself holding down the shift and ctrl key with the right arrow to select a bunch a text for the purpose of deleting it.

The other action is “Kill Line” (Ctrl+K default on Windows). This action deletes from the caret forward to the end of a line. A second Ctrl+K deletes the newline character bringing the next line up. This single action replaces the Shift+End, Delete combo. By default this action is only bound to Ctrl+K in the Command Window. To get it in the Editor, (1) go to File -> Preferences -> Keyboard -> Shortcuts, (2) search for “Kill Line”, (3) select the shortcut and in the table below, (4) click the drop-down arrow and check the “MATLAB Editor” checkbox.

Enabling the kill-line action in the Keyboard Preferences

While you’re in the Keyboard Shortcut preferences, you can browse the list to see the tons of other editing commands that are available.

|
  • print

コメント

コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。