• Login
Community
  • Login

Lua code tab / Табуляция lua кода

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
8 Posts 5 Posters 4.0k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P
    Podstav Podstav
    last edited by May 28, 2018, 7:32 PM

    Please tell me the plugin for tab lua code, not as I can not find (x64)
    ((To level a smooth, ladder)

    Подскажите пожалуйста плагин для табуляции кода lua, не как не могу найти (x64)
    (Что бы выровнять ровненько,лесенкой)

    1 Reply Last reply Reply Quote 0
    • S
      SalviaSage
      last edited by May 29, 2018, 9:53 AM

      Can you clarify on what you are looking for in more detail please?

      1 Reply Last reply Reply Quote 0
      • P
        Podstav Podstav
        last edited by May 29, 2018, 10:36 AM

        how to align the lua code ?

        Example:

        • it was so

        local t = 0
        for i = 1,10 do
        if t == 5 then
        print(t)
        else
        print(t/t)
        end
        t = t + 1
        end

        Example:

        • need to so

        local t = 0
        for i = 1,10 do
        if t == 5 then
        print(t)
        else
        print(t/t)
        end
        t = t + 1
        end

        1 Reply Last reply Reply Quote 0
        • P
          Podstav Podstav
          last edited by May 29, 2018, 10:57 AM

          Example:

          • need to so

          local t = 0
          for i = 1,10 do

          ____if t == 5 then
          ________print(t)
          ____else
          _________print(t/t)
          ____end
          ____t = t + 1
          end

          I did not know how to write the code in the message so added underscore

          S 1 Reply Last reply May 29, 2018, 12:04 PM Reply Quote 0
          • S
            Scott Sumner @Podstav Podstav
            last edited by May 29, 2018, 12:04 PM

            @Podstav-Podstav

            It appears you are seeking a “Lua code beautifier”? If so, Notepad++ cannot really help you with that.

            1 Reply Last reply Reply Quote 0
            • P
              Podstav Podstav
              last edited by May 29, 2018, 12:23 PM

              Yes, in the atom editor this plugin is called beautifier ,and in notepad++ I can not find

              C 1 Reply Last reply May 29, 2018, 3:16 PM Reply Quote 0
              • C
                Claudia Frank @Podstav Podstav
                last edited by May 29, 2018, 3:16 PM

                @Podstav-Podstav

                Install LuaScript plugin via Plugin Manager
                Edit startup file with something like this

                local decreaseIndentPattern = [[^\s*(elseif|else|end|\})\s*$]]
                local increaseIndentPattern = [[^\s*(else|elseif|for|(local\s+)?function|if|repeat|until|while)\b((?!end).)*$|\{\s*$]]
                
                indent_size = 4
                
                function format_code()
                    editor:BeginUndoAction()
                
                    current_indent = 0
                    next_indent = 0
                
                    for i=0,editor.LineCount do
                        current_indent = next_indent
                        start_pos = editor:PositionFromLine(i)
                        end_pos = editor.LineEndPosition[i]
                        if editor:findtext(increaseIndentPattern, SCFIND_REGEXP, start_pos, end_pos) then
                            next_indent = next_indent + indent_size
                        end
                        if editor:findtext(decreaseIndentPattern, SCFIND_REGEXP, start_pos, end_pos) then
                            current_indent = current_indent - indent_size
                            next_indent = next_indent - indent_size
                        end
                        print(current_indent)
                        editor:InsertText(start_pos, string.rep(" ", current_indent))
                    end
                    editor:EndUndoAction()
                end
                
                
                npp.AddShortcut("Source Code Formatter", "Ctrl+D", function()
                  format_code()
                end)
                

                More example are seen here

                Cheers
                Claudia

                1 Reply Last reply Reply Quote 1
                • C
                  chcg
                  last edited by May 29, 2018, 9:29 PM

                  Maybe you want to take a look at
                  https://sourceforge.net/projects/universalindent/files/uigui/UniversalIndentGUI_1.0.2/UniversalIndentGUI_1.0.2_NotepadPPplugin.zip/download
                  or
                  https://code.google.com/archive/p/kereds-notepad-plus-plus-plugins/downloads

                  1 Reply Last reply Reply Quote 0
                  5 out of 8
                  • First post
                    5/8
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors