Button to toggle Tabs/Spaces?
-
@peterjones said in Button to toggle Tabs/Spaces?:
Settings > Preferences > Language > Tab Settings > Replace by space
Yeah, that’s why I was looking for a button option. For me, it’s an issue when I’m dealing with different configuration files since I don’t do any development work, but the files end up looking really weird, I have to spend time reformatting, I have to go through those menus, or I have to use a second different editor.
I do see there is an automatic detection tool, but most of my editing is copying from terminal into blank document, but maybe I should play around with that more.
You wouldn’t happen to know how I might get Tab into a Find or Replace field?
-
If you spend most of your time copying into blank documents, then changing between two languages (which you choose to have different tab/space settings) might be enough. You might even just keep two tabs open, renamed (but not saved) as
tab config
andspace config
, with the language on each tab selected so that each has the right tab setting.To find a tab, you can use Extended Mode or Regular Expression Mode and use
\t
in the FIND WHAT field. -
@myfirstnameispaul said in Button to toggle Tabs/Spaces?:
You wouldn’t happen to know how I might get Tab into a Find or Replace field?
@peterjones said in Button to toggle Tabs/Spaces?:
To find a tab, you can use Extended Mode or Regular Expression Mode and use \t in the FIND WHAT field.
If you want to stick to Normal search mode you can get a tab into the FW box by selecting it first in the editing window and then pressing Ctrl+f. In the FW box it will just look like a really wide space.
-
Using SCI_SETUSETABS could do this for the current buffer, but must be reapplied each time the buffer is activated.
-
But it’s not that easy, is it?
If we load a file and it looks strange, how do we know what to do?
I mean, if a tab is used, how does the script know that it has to be replaced by 2 or 4 or 8 spaces? -
@ekopalypse said in Button to toggle Tabs/Spaces?:
Using SCI_SETUSETABS could do this for the current buffer, but must be reapplied each time the buffer is activated.
Yep, I have a little NppExec script that does this for me on the rare occasion I need to deal with tabs in files (other than Makefile which has “use tabs” set in my Notepad++ preferences); I use convert tabs to 4 spaces by default everywhere else:
::tab NPP_CONSOLE keep IF "$(ARGC)"<="1" THEN // SCI_SENDMSG SCI_GETCURRENTPOS // SCI_SENDMSG SCI_INSERTTEXT $(MSG_RESULT) "$(TAB)" SCI_SENDMSG SCI_ADDTEXT 1 "$(TAB)" ELSE IF "$(ARGV[1])"~="$(ON)" THEN SCI_SENDMSG SCI_SETUSETABS 1 IF "$(ARGC)">"2" THEN SCI_SENDMSG SCI_SETTABWIDTH $(ARGV[2]) ENDIF ELSE IF "$(ARGV[1])"~="$(OFF)" THEN SCI_SENDMSG SCI_SETUSETABS 0 ELSE IF "$(ARGV[1])"~="bs" THEN IF "$(ARGC)">"2" THEN IF "$(ARGV[2])"~="$(FALSE)" THEN SCI_SENDMSG SCI_SETBACKSPACEUNINDENTS $(FALSE) ELSE SCI_SENDMSG SCI_SETBACKSPACEUNINDENTS $(TRUE) ENDIF ELSE SCI_SENDMSG SCI_GETBACKSPACEUNINDENTS ECHO Backspace Unindents = $(MSG_RESULT) ENDIF GOTO END ELSE IF "$(ARGV[1])"~="status" THEN SCI_SENDMSG SCI_GETUSETABS SET LOCAL TABON = $(MSG_RESULT) SCI_SENDMSG SCI_GETTABWIDTH SET LOCAL WIDTH = $(MSG_RESULT) ECHO TABS = $(TABON) ($(WIDTH)) SCI_SENDMSG SCI_GETBACKSPACEUNINDENTS ECHO BS Unindents = $(MSG_RESULT) ELSE GOTO USAGE ENDIF GOTO END :USAGE ECHO Usage: ECHO \$(ARGV[0]) = insert a tab (non-expanded regardless of setting) at current position ECHO \$(ARGV[0]) status = current tab setting ECHO \$(ARGV[0]) $(ON) [W] | $(OFF) = enable tabs (no space convert) using optional W tab width | disable (convert to spaces) ECHO \$(ARGV[0]) bs $(ON) | $(OFF) = enable | disable backspace unindents :END
Note the
$(ON)
and$(OFF)
are set in my NppExec startup:... SET TRUE=1 SET FALSE=0 SET ON=$(TRUE) SET OFF=$(FALSE) ...
Cheers.
-
I get the mental image of the OP playing a version of WHACKAMOLE with tab characters.
-
Sorry to re-open such an old thread. Don’t want to run a necromantic job… but I’ve seen the option to switch between the indent singe temporarily per document via a switch in the status line in several copycats of Notepad++. why not re-copy this into notepad++!? Perhaps this is an idea for an feature request which shouldn’t be difficult to implement, if I understand the implications right…
what you think guys?
-
That was talked about more last autumn in this conversation, though that specific discussion didn’t get very detailed.
I am remember something from approximately the same timeframe, where I thought that someone investigated in more detail, and (IIRC) found that “shouldn’t be difficult to implement” doesn’t always equate to “actually isn’t too difficult to implement” – but I cannot find either a post here or the coment that I vaguely remember in any issues or PRs, even though there were other tab/indentation fixes made last autumn…
Hopefully someone who remembers (or is better at searching than I am) will be able to remember/find the discussion I am thinking about.
update: ugh, per this comment, it was earlier than I was thinking, and the user who I thought had the best chance of remembering/finding it couldn’t find it even then. :-( So now I have confirmation that someone else also remembered that discussion, but still haven’t been able to find it. :-(
-
@Alan-Kilborn messaged me a link to this post, where he shared a script for the PythonScript plugin, which can be used to set the current file to either tabs or spaces
Useful link: FAQ: How to install and runscripts with PythonScript plugin – also includes instructions for assigning a keyboard shortcut. And you can even use the Plugins > PythonScript > Configuration… to add a script to the toolbar, allowing you to have a toolbar button to activate it.