0

In some of the IDEs you can equalize the indentation of a selection of lines according to previous line indentation by some shortcut. Such a shortcut is Ctrl+I in Matlab m-file editor. I was wondering if there exist equivalent functionality for texstudio, or can it be implemented using javascript functionality of it.

  • Revision:

I wrote the following script for the this task. However, it just correct one line. The question is how to include a block of lines also

%SCRIPT
l = cursor.lineNumber();
txt1 = editor.text(l-1);
txt2 = editor.text(l);
pad = txt1.match(/^\s+/);
txt2 = txt2.replace(/^\s+/,'');
if (pad == null)
    pad = ''
cursor.eraseLine(); 
cursor.insertText(pad+txt2+'\n', false) 
2

There is no built-in functionality for this. But yes, you can implement this by a JavaScript User Marco.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.