Change tab size through macro?

Change tab size through macro?

4
NewbieNewbie
4

    Feb 28, 2006#1

    Hello,

    My company does work in both Linux and Windows environments, and there is no 'standard' indent value for tabs, but most everyone uses 4 or 8 character indenting. And as I'm sure you all know, it's a real pain to run across files edited in 'tab 4' style that have embedded spaces instead of tabs when you are working in 'tab 8' mode.

    I am looking or a way to switch between tabs at 4 characters and tabs at 8 characters (or to select a tab indent value) without having to go through the 'Advanced Configuration' settings... say something that could be done as a macro.

    Any suggestions?

    TIA,

    Steve

    6,687587
    Grand MasterGrand Master
    6,687587

      Feb 28, 2006#2

      That's easy. First replace all strings with exactly 8 spaces by 1 tab. Then replace all tabs by 4 spaces.

      Code: Select all

      Top
      Find "        "
      Replace All "^t"
      Find "^t"
      Replace All "    "
      Same method for conversion from 4 to 8 spaces. First replace all strings with exactly 4 spaces by 1 tab. Then replace all tabs by 8 spaces.

      Code: Select all

      Top
      Find "    "
      Replace All "^t"
      Find "^t"
      Replace All "        "
      Before closing the file you should convert all 4 or 8 spaces back to tabs or the 4 spaces.
      Best regards from an UC/UE/UES for Windows user from Austria

      4
      NewbieNewbie
      4

        Feb 28, 2006#3

        Hi Mofi,

        I appreciate the reply, but I'm not looking to CONVERT tabs to spaces (or vice versa)... I'm looking to change the way I see tabs in my editor, as either 4 or 8 characters (as currently configured through Advanced->Configuration->Word Wrap/Tab Settings).

        I was hoping to find a way to change the 'Tab Stop' and 'Indent Spaces' Values without having to traverse the menu. I do not want to modify the file.

        Thanks again,

        Steve

        344
        MasterMaster
        344

          Mar 01, 2006#4

          Hi,

          Well, if I understood it right:

          Just change the value of this line
          Indent1=4
          in uedit32.ini to 4 or 8 before starting UE.
          You can either start UE with a Parameter to a specific ini-file or work with ONE uedit32.ini and change this value before stating UE.
          Many ways lead to Rome there...

          rds Bego
          Normally using all newest english version incl. each hotfix. Win 10 64 bit

          4
          NewbieNewbie
          4

            Mar 01, 2006#5

            Again, thanks for the advice... but perhaps I haven't explained what I'm looking for as precisely as I thought.

            I'm looking for a way to change the 'Tab Stop' and 'Indent Spaces' values, on-the fly, without altering the file I'm viewing, through the use of a macro or other means without having to navigate the menu tree. Ideally this would be something you could attach to a button on a toolbar or a hotkey.

            I"m starting to believe that this is not a feature of UE at this time. Though I'm sutrprised it hasn't been asked for before... I see a lot of mixed VI/Windows environments where tab stop sizes are different, especially when viewing C and assembly files (C files at 4 character tabs, assembly at 8). Wouldn't it be nice to be able to change tab stop sizes on the fly?

            Thanks once more,

            Steve

            6,687587
            Grand MasterGrand Master
            6,687587

              Mar 01, 2006#6

              Do you already know, that you can set different tab stop and indent values based on the file extension?

              You can already set a tab stop of 4 for *.c and *.h files and a tab stop of 8 for *.asm, *.src and *.lst files.

              Even better you can set for example for assembler files that first tab stops at column 12, second tab at 16, third at 25 and further tabs at every 8 to get correct aligned the assembler code with only 3 tabs. Example:

              Label:»MOV»R15,#000Fh»; comment

              That's the reason why nobody has needed till now to change the tab settings on the fly. The only problem is that for example 1 developer uses a tab stop of 3 and another developer a tab stop of 4 and both are editing the same source files or files with the same extension. But there is also a solution for this problem: either with the macros above or better change the file extension for example from .c to .c4 or .c3 and specify the tab stop value 4 for extension .c4 and 3 for .c3.
              Best regards from an UC/UE/UES for Windows user from Austria

              4
              NewbieNewbie
              4

                Dec 07, 2009#7

                sstrubli wrote:I'm looking for a way to change the 'Tab Stop' and 'Indent Spaces' values, on-the fly, without altering the file I'm viewing, through the use of a macro or other means without having to navigate the menu tree. Ideally this would be something you could attach to a button on a toolbar or a hotkey.
                I'm reviving this thread because I'd like to request exactly the same feature (still absent as of UltraEdit 15.20). Frequently I switch back and forth between source files from different third-party projects written in the same programming language. Different developers create code with different tab stops and changing between tab settings is something I do frequently. UltraEdit currently makes this extremely cumbersome because:
                • I can't see what my current tab settings are, unless I go to Advanced -> Configuration -> Editor -> Word Wrap/Tab Settings (4 clicks - assuming I remember correctly which of the 10+ Configuration categories I'm looking for)
                • I can't change the tab settings unless, likewise, I go through the 4-click process and then change 3 settings by hand (Use spaces in place of tabs, Tab Stop value, and Indent spaces)
                • UE will only remember one set of tab settings per file extension, which is of no help when switching between projects written in the same language with different tab stops
                Any or all of the following would be huge improvements here.
                • Show an indicator of the current tab stop settings (e.g. SPC/4/4 or TAB/4/2) in the status bar, similar to the current insert/overwrite/caps lock/text file format indicators
                • Provide a direct menu option or toolbar button for switching between user-defined tab settings
                • Allow tab stop settings to be stored and loaded with project settings
                • Allow tab stop settings to be changed directly using an UltraEdit JavaScript method, so I can create my own key shortcut/menu option/toolbar button
                Renaming another developer's files to a different file extensions in order to work around UE's limitation here is, I think, an unworkable suggestion. Tab stops vary from project to project and UltraEdit settings should work the same way. At the very least, UE should make it possible to view and switch these settings without navigating to a configuration setting buried several layers deep.

                3
                NewbieNewbie
                3

                  Mar 04, 2010#8

                  I emailed IDM in 2006 requesting a similar feature to that mentioned by chrisdfeld above. I seem to recall that I got a reply that wasn't really applicable to my requirement.

                  In my case I often use UltraEdit to manipulate data files as in data cleansing. Often these are CSV files or files with rows of data and tabs between the fields in each row. In order to visually check a file I need to set the tab stop appropriate to the data in each field column. Currently this is real pain having to navigate through the configuration menu to the TAB Stop value setting.

                  In addition to chrisdfeld's good suggestions, what would be incredibly helpful would be to be able to right click on the Ruler and set/unset a tab stop. i.e. similar to Microsoft Word. Is there any reason why this is difficult or a bad idea to add as a feature to UltraEdit?

                  I have now emailed IDM again to request a simpler way to change the Tab Stop value.

                  -- Rob --
                  -- Rob --

                  6,687587
                  Grand MasterGrand Master
                  6,687587

                    Mar 05, 2010#9

                    Rob, why do you not convert your CSV files to fixed column using Column - Convert to Fixed Column and after finishing editing back to a CSV file using Column - Convert to Character Delimited which are designed for working with CSV files?
                    Best regards from an UC/UE/UES for Windows user from Austria

                    3
                    NewbieNewbie
                    3

                      Mar 05, 2010#10

                      Thanks for your reply Mofi and helpful suggestion, but I'd be converting back and forth all day. i.e. like using the configuration menu, I'd be doing additional onerous mouse and click work that would be unnecessary if I had a more convenient and efficient way to change the TAB Stop value.
                      -- Rob --
                      -- Rob --

                      25
                      Basic UserBasic User
                      25

                        Dec 06, 2013#11

                        +1 to the request of "means to change the TAB setting on the fly".
                        I work frequently with other people's code, each with their own coding conventions, which includes indentation step.
                        2, 3, 4 are the most common (covers 99.9% of what I have to work with).
                        Actual TAB characters are not allowed, but that's only one of the few rules that is agreed on and followed.
                        For the sake of maintainability, I have to make changes to the code without changing anything that already works just fine.
                        Thus the need to change the TAB setting on the fly.

                        Having TAB setting set as a project property would not work for me. The same project can have files with different indentations.

                        A TAB setting per extension, won't solve things for me, either.

                        I never wrote a macro, so I don't know whether this is possible for this setting or not.
                        I have avoided learning them so far, but this is the 1st time that I'm getting serious about trying them. If it has a chance of working.
                        I figure that I need 3 macros: "TAB=2", "TAB=3", "TAB=4" and some way of creating toolbar buttons to call them. Is this possible? Is there an example, that I can follow (as a macro newbie)?

                        -- VU

                        PS: Happy St Nick's day - if you're lucky enough to have been visited :)

                        6,687587
                        Grand MasterGrand Master
                        6,687587

                          Dec 07, 2013#12

                          None of the settings in Advanced - Configuration can be changed by an UltraEdit macro or UltraEdit script. And it is also not possible to execute macros from a toolbar in current version UE v20.00.0.1056.

                          Two suggestions for working with different tab settings:
                          • Usage of multiple INI files each with a different tab setting for same type of file (file extension) as explained in topic having a per project configuration.
                            The topic explains how to use a separate INI file for a specific project. But it is not really necessary to use a project, just a different INI file when loading for example a *.c file which should be edited with a tab stop value of 2, and another INI file for editing a *.c file with tab stop value of 3 additionally to standard uedit32.ini for editing *.c files with a tab stop value of 4.
                          • Usage of different tab stop values for different file extensions and changing temporarily the file extensions for a file.
                            For example by default a tab stop value of 4 is configured for *.c files. Additionally there is a configuration for *.c2 files with a tab stop value of 2 and one more for *.c3 files with a tab stop value of 3.
                            After loading a *.c file which should be edited with a tab stop value of 2, the command File - Rename File is executed from the menu, the toolbar or by hotkey to change the file extension from c to c2. Once finished with editing the command is executed again for changing the file extension back to just c.
                            For this workaround the file extensions C2 and C3 should be added to the wordfile c_cplusplus.uew used for syntax highlighting C/C++ files.
                            And I suggest to enable Tab colors by file specification and configure a separate color for files with extension c2 and for files with extension c3 to make it better visible that the file extension is temporarily different.
                          If both of my suggestions are not acceptable for any reason, there is no other method than always opening the tab settings configuration dialog and change the tab stop value.

                          One more suggestion using a third party tool. With AutoHotkey it is perhaps possible to create a script for opening the configuration dialog, switching to the Word Wrap / Tab Settings dialog, selecting the configuration for files with extension ???, change the tab stop value and close the configuration dialog with OK. I'm not using AutoHotkey, but perhaps this is an alternate solution for quickly changing the tab stop value for a file.
                          Best regards from an UC/UE/UES for Windows user from Austria

                          25
                          Basic UserBasic User
                          25

                            Dec 10, 2013#13

                            Thank you Mofi,
                            None of the settings in Advanced - Configuration can be changed by an UltraEdit macro or UltraEdit script. And it is also not possible to execute macros from a toolbar in current version UE v20.00.0.1054.
                            So the macro scripts are for manipulating files and file content but not the tool. Good to know. I think that they should make an exception to some benign setting changes via scripts.
                            Re 1st solution:
                            I have projects with files using mixed tab/indent styles; same extension. I really figure that the best way to deal with this situation is to be able to change the TAB setting on the fly.

                            Re 2nd solution:
                            I don't want to mess with file renames (it impacts how SVN content shows elsewhere).

                            I went with AutoHotkey.
                            Win 7 x64 and it appears to be working.
                            It took a bit of time to weed out issues but here it is - my script to map "ALT+Numpad2" to force TAB & indent setting of 2:

                            Code: Select all

                            SetTitleMatchMode, 2       ; string match anywhere in the title
                            CoordMode, Mouse , Window  ; should be as default
                            
                            !Numpad2::
                            IfWinActive, - UltraEdit
                            {
                              Send {Esc}{Esc}{Alt}AC
                              Sleep 100      ; Wait ... ms.
                              Click 203,140  ; scroll config menu to the top
                              Click 203,140
                              Click 203,140
                              Click 64,128
                              Send {Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}
                              Send {Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}2
                              Send {Tab}2
                              Send {Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Enter}
                              MsgBox ,,,"TAB=2",1
                            } else {
                              MsgBox "ALT+2: UltraEdit window not active.".
                            }
                            return
                            
                            For anybody trying to use it, warning: it is a bit slow but it sure beats going through menus every time and decreases office tensions caused by lack of uniform coding rules.
                            Thanks again.
                            Cheers - v/u

                            3
                            NewbieNewbie
                            3

                              Dec 29, 2013#14

                              Is the request for this feature (quick way to set TAB stop value on the fly) still on the backlog?

                              I raised this request in 2003, again in 2006 and then once more in 2010 when I saw this forum thread.
                              I find it strange with all the amazing features of UltraEdit that such a seemingly simple capability has not been implemented in 10 years.

                              All the suggestions and solutions to date miss the point of what my requirement is - something apparently shared by others - to change the tab stop setting not per project nor per file type but on the fly, sometimes multiple times while editing a file simply to view the text in different ways.

                              In my case when working with tab delimited data (integration and data migration projects) I need to change the Tab Stop value multiple times so that I can view tab delimited data in columns where the width of the column (tab stop) is greater than the longest string in each column.

                              For 10 years the only apparent way to do this is via the Configuration menu and I am hoping that some time before I retire there will be an easier way.

                              Currently, the right click menu includes "Format | Paragraph Formatting | Paragraph Setup/Formatting" with various justification and indent/hanging capabilities. Surely the setting to the TAB stop value is a more basic capability than these more sophisticated alignment features??
                              -- Rob --

                              6,687587
                              Grand MasterGrand Master
                              6,687587

                                Dec 30, 2013#15

                                touriga wrote:Is the request for this feature (quick way to set TAB stop value on the fly) still on the backlog?
                                You better ask this IDM support by email. I think, no user can answer that.

                                As far as I know the implementation priority for new features depends on how many user request a feature and of course on what management of IDM thinks is useful for a large number of UltraEdit users. Therefore it is always good on feature requests to write what should be added to UltraEdit in as much details as possible and who would benefit on this new feature on which tasks.

                                I have not requested a feature for quickly changing the tab stop value, but I would express such a feature request as follows:


                                Request for a feature to set tab stop value(s) on active file different to default setting

                                There is the possibility to define the tab stop value(s) for files based on file extension and I make already use of it.

                                But it would be nevertheless great if there would be a menu item like Set Tab Stop Value in menu Format in the group with the other 3 tab related commands which opens a small dialog in which one or more tab stop values separated by commas could be entered being applied to active file only on closing the dialog with button OK. The edit field in this dialog should display the currently active tab stop value(s) for the active file on opening and entire edit field content should be selected already so that typing immediately replaces the current value(s).

                                A feature to define the tab stop value(s) for the active file different to what is configured for this file in Word Wrap / Tab Settings configuration dialog could be very useful for many users of UltraEdit.

                                Programmers are often in the situation that a source file must be viewed/edited written by somebody else who used a different tab stop value than the programmer uses. A feature to quickly change the tab stop value for the active source file only without the need to change the tab stop value for all source files in configuration would be surely very helpful for many programmers, especially those working on open source projects or using source files of other (open source) projects in their own projects.

                                And users of UltraEdit viewing/editing tab delimited CSV files would benefit from such a feature as they could quickly change the tab stop values for a loaded CSV file without the need to change the standard tab stop value settings for CSV files or convert the file to fixed width and later convert the file back to character delimited.

                                Last many HTML, XHTML and XML files have indents made by horizontal tabs. But there is no worldwide standard for the tab stop value of such files. Therefore looking on or editing of HTML, XHTML or XML files not created by a user with the preferred tab stop value setting is not easy and a feature to quickly change the tab stop value setting for such a file created by somebody else without the need to change the preferred tab stop value for such files would be most likely great for many users of UltraEdit using UE to view/edit HTML or XML files.

                                In my point of view it is not really necessary that UltraEdit remembers on closing of the file the entered tab stop value(s) for those files on which the tab stop value(s) were set different to the standard tab stop value(s) as configured in the Word Wrap / Tab Settings configuration dialog for files with an extension of active file. But that could be an interesting additional feature for programmers who really use source files of open source projects in their own projects and do not reformat those source files to their tab stop value setting.

                                The command Set Tab Stop Value in menu Format should be also available in Key Mapping configuration dialog for being able to assign a hotkey/chord to this command to open the dialog quickly by keyboard. And for those users who prefer clicking on toolbar icons for executing a command, this command should be also available in the toolbar customization dialog as well as in the menu customization dialog. The command makes also sense in the document window popup menu as it changes the tab stop value(s) for the active file only.
                                Best regards from an UC/UE/UES for Windows user from Austria

                                Read more posts (1 remaining)