Getting the actual length of a tab

25 views
Skip to first unread message

Charly Dante

unread,
Apr 2, 2017, 6:34:02 AM4/2/17
to scintilla-interest
Hi,

I want to add to my editor the option to convert all tabs in a document to spaces. Say my tab-width is 8 spaces, I just tried something like replace_all(text, "\t", "        ");.

However, this doesn't work as expected, because not all tabs might have an actual length of 8. I want to replace each tab with exactly as many whitespaces, as it occupies in the document.

So, is there a way to get the effective length of a tab in whitespaces?

Colomban Wendling

unread,
Apr 2, 2017, 10:02:51 AM4/2/17
to scintilla...@googlegroups.com
col + tab_width - (col % tab_width)

is enough if all tab stops are at tab_width. Otherwise (or
alternatively), play with SCI_GETCOLUMN:
http://scintilla.org/ScintillaDoc.html#SCI_GETCOLUMN

Regards,
Colomban

Charly Dante

unread,
Apr 4, 2017, 5:07:07 PM4/4/17
to scintilla-interest
Thanks, I will try that.
Reply all
Reply to author
Forward
0 new messages