Reply To: Global replace of tab char does not always work

Product Compare Forums Multi-Edit Support Global replace of tab char does not always work Reply To: Global replace of tab char does not always work

#6877
Bret Sutton
Participant

I think you’re in Overwrite mode, which I recall is your default setting. If you switch to Insert mode, and have Tab Expand set to Tabs, then Tab_Right will insert a tab character.
Yeah, I keep forgetting I’m the odd man out. My users keep reminding me to test my macros in Insert Mode. Duh. However…keep reading.
Ctrl-I inserts a tab because in your key mapping Ctrl-I isn’t assigned to any command; but in the default CUA key mapping Ctrl-I is assigned to Incremental Search. What I said, more or less.

I also see in your BJS key mapping you have the TAB key assigned to NWSTEXT.mac, a file I don’t have. That macro simply does a Tab_Right. I didn’t want my tab key doing auto indents or smart tabbing. Those functions are assigned to other key combos.

To summarize, here’s a nice liittle table-of-sorts. It adds two possibilities we haven’t discussed yet: adding a character way to the right of the EOL of an existing line; and adding a character in the same position, on a line that doesn’t have anything on it yet – not even spaces. (It doesn’t matter whether it is before or after EOF.) Try those; they are fun to watch in hex mode.[code:1ren4di1] expand tabs expand spaces

Tab_Right:
insert mode tabs spaces
overstrike mode spaces spaces
Unassigned tab key:
insert mode tabs spaces
overstrike mode tabs spaces
Any char on an empty line:
insert mode tabs spaces
overstrike mode tabs spaces
Any char on an existing line:
insert mode spaces spaces
overstrike mode spaces spaces[/code:1ren4di1]
I’m not sure how to justify the three exceptions in the expand-to-tabs column. I think that, in expand-to-tabs mode, tabs should always be generated where possible.

Do you think the program should be changed so Tab_Right overwrites the current character with a tab character when Tab Expand is set to Tabs? Then why shouldn’t it overwrite with spaces when Tab Expand is set to spaces? Oh, my. Now you’re making me think. Of course we don’t want to overwrite anything except spaces, in either mode. Which means that Tab_Right in expand-to-tabs mode would have to be smart enough to scan ahead to the next tab stop and see if there’s anything there. If only whitespace, it can overwrite those spaces with a \x09 followed by the filler character (\x01 or \xFF) out to the next tab stop. If other characters, it will not do anything except move the cursor (the same as in expand-to-spaces mode). It could get a little fancier, but I don’t think it would be worth the additional effort.