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.
    • Podstav PodstavP
      Podstav Podstav
      last edited by

      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
      • SalviaSageS
        SalviaSage
        last edited by

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

        1 Reply Last reply Reply Quote 0
        • Podstav PodstavP
          Podstav Podstav
          last edited by

          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
          • Podstav PodstavP
            Podstav Podstav
            last edited by

            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

            Scott SumnerS 1 Reply Last reply Reply Quote 0
            • Scott SumnerS
              Scott Sumner @Podstav Podstav
              last edited by

              @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
              • Podstav PodstavP
                Podstav Podstav
                last edited by

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

                Claudia FrankC 1 Reply Last reply Reply Quote 0
                • Claudia FrankC
                  Claudia Frank @Podstav Podstav
                  last edited by

                  @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
                  • chcgC
                    chcg
                    last edited by

                    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
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors