NSTextView: replace all tabs

I have NSTextViewwhere I would like to use spaces instead of tabs. Although I would be replaceOccurrencesOfString:withString:options:range:in textStorageWillProcessEditing:mine textview delegate, but it does not work (undoing breaks).

Please, does anyone know how to implement such functionality? Is there any other way to do this?

Edit: this is what I have in the method textStorageWillProcessEditing::

ts = [notification object];
[[ts mutableString] replaceOccurrencesOfString:@"\t"
                                    withString:@"  "
                                       options:NSLiteralSearch
                                         range:[ts editedRange]];
+3
source share
1 answer

You can override the keyUp: method. If event.keyCode == keycodefortabwhichidontknow :) then you can insert four spaces.

And if, of course, just call [super keyDown: theEvent];

0
source

All Articles