Menu

Hanging Indents

HarDar
2009-04-16
2012-11-13
  • HarDar

    HarDar - 2009-04-16

    Is there no way in Notepad++ to have hanging indents as a default display when a line wraps (ala Crimson Editor). I'm trying to switch over but my old stuff (tons of it) looks horrible.

     
    • Jan Schreiber

      Jan Schreiber - 2009-04-26

      OK, thanks for the reply. I haven't been able to figure out a way to do it either. Having two macros, bound to something like Alt+2 and Alt+Shift+2 respectively, is almost as good.

       
    • cchris

      cchris - 2009-04-20

      The following macro definition will do, inside the <Macros>...</Macros> area in Shortcuts.wml:

              <Macro name="WrapIndent" Ctrl="yes" Alt="yes" Shift="no" Key="98">
                  <Action type="0" message="2464" wParam="5" lParam="0" sParam="" />
              </Macro>

      5 is some random integer you can set as you wish, it is the width, in characters, of the overhang indent. The macro is affected to Ctrl-Alt-2, but you can change that, as well as the name, from the shortcut mapper. And 2464 is the number of the relevant Scintilla message.

      CChris

       
      • HarDar

        HarDar - 2009-04-23

        Thanks for the answer. Doesn't seem to work at least at first try. Will try to debug.  Anyway, this looks like I will have to do it every line. I'd rather have it as default of course. But I'll give it a try.

        Have re-posted this question because this thread does not seem to appear in the thread list??? Will try to delete new post.

         
      • Greg

        Greg - 2009-04-23

        Chris,

        I tried this but I could not get it work either. I think 'Shortcuts.wml' is a typo, should it be 'Shortcuts.xml' in the AppData NP++ directory??

        I added the macro to the AppData file but I can't get it recognised by NP++. It doesn't show in the Macro menu. What stupid mistake am I making?

         
    • cchris

      cchris - 2009-04-23

      "Of course" the file to edit is shortcuts.xml . People like me desperately need a "edit last post" feature...

      I assume there is one such file in your %APPPDATA%\Noteped++ folder, and none in the folder notepad++.exe is in.

      Open the file and search for the text "</Macros> " (without the quotes).

      If it is not found (which I doubt), then add after the opening < InternalCommands /> tag the two following lines:

      <Macros>
      </Macros>

      So now you have </Macros> on a line by itself, regardless of it being there prior. Above this line, insert the following:
              <Macro name="hang" Ctrl="yes" Alt="yes" Shift="no" Key="98">
                  <Action type="0" message="2464" wParam="5" lParam="0" sParam="" />
              </Macro>

      Save and close shortcuts.xml .
      Open Notepad++.
      If wrap mode is not activated, activate it.
      Now execute the "hang" macro by either using the Macro menu or hitting Ctrl-Alt-NumPad2. Unless you want to modify those bindings prior.

      Now, any line that was wrapped has 5 chars of overhang indent. All secundary lines (ie those that result from wrapping) are affacted. If there was no wrapping line, then resize the window so as to reduce its width. On releasing the mouse, some (more) lines will wrap.

      If you execute the macro with word wrap off, and then turn word wrap on, the lines will wrap with your indent.

      If you used Notepad++ to edit shortcuts.xml, here is a gotcha: Notepad++ reads shortcuts.xml only once when it opens. As a result, your changes, and the new macro, will show up when you close and then restart N++. I haven't tried playing with multiple instances.

      Still doesn't work?

      CChris

       
    • Greg

      Greg - 2009-04-23

      Hi Chris,

      You wrote:

      "I assume there is one such file in your %APPPDATA%\Noteped++ folder, and none in the folder notepad++.exe is in. "

      I have a shortcuts.xml file in both my AppData and my NP++ exe folder. Guess which one I tried first. :-)

      I followed you instruction again and it still didn't work but...

      "If you used Notepad++ to edit shortcuts.xml, here is a gotcha: Notepad++ reads shortcuts.xml only once when it opens. As a result, your changes, and the new macro, will show up when you close and then restart N++."

      In fact the gotcha is worse than you think. After a while I realised that NP++ was not updating the shorcut.xml file. Why? Because NP++ saves to the shortcut.xml file as it closes. This means you can't use NP++ to edit the shortcut file!

      By using a different editor, with a name similar to NP++, I made the edits and when I next opened NP++, thre was your macro.

      All working now, and even more learned about the workings of Notepad++.

      Cheers Chris.

       
    • cchris

      cchris - 2009-04-23

      Hmm.. Actualy I did use another text editor, if only because it displays better in 800x600 resolution.

      One thing you could do to use N++ only is:

      1 copy shortcuts.xml to a different folder
      2 edit that file
      3 outside N++, and the latter being closed, clobber the old shortcuts.xml using drag and drop.

      CChris

       
    • Jan Schreiber

      Jan Schreiber - 2009-04-24

      Is there some clever way to make the keyboard shortcut act as a toggle, something like binding it to another macro with wParam="0" from inside the first macro and vice versa? Would be nice to have, but of course not necessary.

       
    • cchris

      cchris - 2009-04-24

      If there is any, it outsmarts me so far :->

      I have tried the following, which DOESN'T work:

      1/ recording "Open in another instance" command as macro - doesn't record
      2/ record a macro modification event - neither

      So the only closest thing I can think of is having two macros, one for 5 and oe for 0 (and perhaps more), and use them as appropriate. Unless someone is more clever.

      CChris
      PS: a DOS editor I had mentioned earlier (Bingo) would allow that by editing the UI plain text file using another macro, generating the new binary UI file thru a shell command and then reloading it on the fly.

       
MongoDB Logo MongoDB