Git Product home page Git Product logo

daddel80 / notepadpp-multireplace Goto Github PK

View Code? Open in Web Editor NEW
17.0 17.0 6.0 40.5 MB

MultiReplace is a plugin for Notepad++ enabling multi-string replacement, allowing list saving and loading. It provides CSV syntax highlighting and enabling precise column targeting. Additionally, it introduces conditional and computational operations within the replacement string.

License: GNU General Public License v2.0

C 66.25% C++ 29.92% HTML 3.82%
column-filter computational-replacement csv delimited delimited-data delimited-file filter-replacement find-and-replace notepad-plus-plus notepad-plusplus-plugin notepadplusplus replace-text replacement string-replace syntax-highlighting

notepadpp-multireplace's People

Contributors

alexeristgit avatar conky77 avatar daddel80 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

notepadpp-multireplace's Issues

Version is misreported

See:

PS VinsWorldcom C:\usr\bin\npp64\plugins\NppMultiReplace > (Get-Item .\NppMultiReplace.dll).VersionInfo

ProductVersion   FileVersion      FileName
--------------   -----------      --------
4.3              4.3              C:\usr\bin\npp64\plugins\NppMultiReplace\NppMult...

Coming from:

#define VERSION_VALUE "4.3\0"

all open documents

Is there a way to do a search and replace on all open documents? You can do this with the built-in function. Thanks!

32-bit build failing due to sign mismatch warning and treat warnings as errors

When building the 32-bit version, I'm getting several warnings about sign mismatch in "src\MultiReplace.cpp":

notepadpp-multireplace\src\MultiReplace.cpp(448,42):  warning C4018: '>=': signed/unsigned mismatch [notepadpp-multireplace\vs.proj\NppMultiReplace.vcxproj]
notepadpp-multireplace\src\MultiReplace.cpp(467,42):  warning C4018: '>=': signed/unsigned mismatch [notepadpp-multireplace\vs.proj\NppMultiReplace.vcxproj]
notepadpp-multireplace\src\MultiReplace.cpp(502,129): warning C4389: '==': signed/unsigned mismatch [notepadpp-multireplace\vs.proj\NppMultiReplace.vcxproj]
notepadpp-multireplace\src\MultiReplace.cpp(1077,14): warning C4018: '<':  signed/unsigned mismatch [notepadpp-multireplace\vs.proj\NppMultiReplace.vcxproj]
notepadpp-multireplace\src\MultiReplace.cpp(1131,30): warning C4018: '>=': signed/unsigned mismatch [notepadpp-multireplace\vs.proj\NppMultiReplace.vcxproj]
notepadpp-multireplace\src\MultiReplace.cpp(1290,28): warning C4018: '<=': signed/unsigned mismatch [notepadpp-multireplace\vs.proj\NppMultiReplace.vcxproj]
notepadpp-multireplace\src\MultiReplace.cpp(1581,40): warning C4018: '<':  signed/unsigned mismatch [notepadpp-multireplace\vs.proj\NppMultiReplace.vcxproj]

The build fails since in "vs.proj\NppMultiReplace.vcxproj", the <TreatWarningAsError>true</TreatWarningAsError> is set in all the ItemDefinitionGroup's.

You could just set that to false for the 32-bit build configurations. Better would be to examine how / why the comparisons are between int and size_t (in most cases) and see if that could be fixed or just cast the size_t to int minding:

https://stackoverflow.com/questions/3642010/can-i-compare-int-with-size-t-directly-in-c

Cheers.

Extra files from template

The files:

  • src/DockingFeature/GoToLineDlg.cpp
  • src/DockingFeature/GoToLineDlg.h
  • src/DockingFeature/goLine.rc

seem to be unnecessary cruft from the template plugin.

Regexp rename with a counter

Is there a way?

I need to rename key names in an ini file:

[section1]
Buttoncount=2

button1=...
cmd1=...
menu1=...

button2=...
cmd2=...
menu2=...

I want to insert a button (block of keys) between 1 and 2 and call the replacer to rename all keys using the counter variable:

[section1]
Buttoncount=2

button1=...
cmd1=...
menu1=...

; inserted values
button=...
cmd=...
menu=...

button2=...
cmd2=...
menu2=...

32-bit warning as error again

notepadpp-multireplace/src/MultiReplace.cpp:

677:     for (int i = 0; i < replaceListData.size(); i++) {

should be size_t

Issues when text has special character like colon :

Hello, Trying to replace a set of strings into a file but it fails when the character : is in the find text. It is not being replaced.

Example below:

1,Other Options,Other Options [NE],1,1,0,0,0
1,Please choose one:,Please choose one: [NE],1,1,0,0,0
1,Deduct From,Deduct From [NE],1,1,0,0,0
1,Deducted From:,Deducted From: [NE],1,1,0,0,0

rows 1 and 3 are OK
rows 2 and 3 are not being replaced in the file because of the colon at the end.

thank you in advance!

Ability to translate the plugin

Good afternoonю If it's possible and if it's not difficult, could you add the ability for everyone (me in particular) to translate your plugin into their native language? For example, how this is implemented in NotePad++: there is an XML file that can be edited and get the result that you need. I use your plugin to modify games, correct official localizations, and it’s just nice when all the space around you is in your native language :)

Thank you!

Wrong dlgID in multiReplace()

The member dlgID should:

        // the dlgDlg should be the index of funcItem where the current function pointer is
        // in this case is DOCKABLE_DEMO_INDEX

That is 0 from:

notepadpp-multireplace/src/PluginDefinition.cpp:

71:     setCommand(0, TEXT("&Multi Replace && Mark"), multiReplace, NULL, false);
72:     setCommand(1, TEXT("&About"), about, NULL, false);

however, it is set to 3.

Dots incorrect replacement in regexp expressions

File:

# dest: "d:\blabla"
#> c:\test1\test1.aaa|test1.txt.lnk
e:\blabla\|test1.txt
#> c:\test2\test2.bbb|test2.txt.lnk
e:\blabla\|test2.txt

Want to replace to:

# dest: "d:\blabla"
#> c:\test1\test1.aaa|test1.txt.lnk
c:\test1\test1.aaa|test1.txt
#> c:\test2\test2.bbb|test2.txt.lnk
c:\test2\test2.bbb|test2.txt

The expression:

1,"^([^\\r\\n\\|]+)(?:\\|([^\\r\\n\\|]+)(?:\\|([^\\r\\n\\|]+)(?:\\|([^\\r\\n\\|]+))?)?)?","init({DESTDIR="""",REPLACETO=""""}); if CAP1 ~= nil and string.sub(CAP1,1,3) == ""#> "" then DESTDIR=string.match(string.sub(CAP1,4,-1),""^(.+)\\\\"") elseif CAP1 ~= nil and string.sub(CAP1,1,1) ~= ""#"" and string.len(DESTDIR) > 0 and CAP2 ~= nil then REPLACETO=DESTDIR..""\\\\|""..CAP2 end; cond(CAP1 ~= nil and CAP2 ~= nil and string.len(CAP1) > 0 and string.len(CAP2) > 0 and string.sub(CAP1,1,1) ~= ""#"" and string.len(REPLACETO) > 0, REPLACETO)",0,0,1,0,1

Result:

# dest: "d:\blabla"
#> c:\test1\test1.aaa|test1.txt.lnk
c:\test1\test1|test1.txt
#> c:\test2\test2.bbb|test2.txt.lnk
c:\test2\test2|test2.txt

Parentheses incorrect replacement in regexp expression

File:

c:\dir1\|aaa (bbb) ccc
#> d:\dirA\ddd
c:\dirB\|aaa (bbb) ccc
#> d:\dirC\ddd
c:\dirD\|bbb) ccc

Want to replace to:

c:\dir1\|aaa (bbb) ccc
#> d:\dirA\ddd
d:\dirA\|aaa (bbb) ccc
#> d:\dirC\ddd
d:\dirC\|bbb) ccc

The expression:

Selected,Find,Replace,WholeWord,MatchCase,UseVariables,Regex,Extended
1,"^([^\\r\\n\\|]+)(?:\\|([^\\r\\n\\|]+)(?:\\|([^\\r\\n\\|]+)(?:\\|([^\\r\\n\\|]+))?)?)?","init({DESTDIR="""",REPLACETO=""""}); if CAP1 ~= nil and string.sub(CAP1,1,3) == ""#> "" then DESTDIR=string.match(string.sub(CAP1,4,-1),""^(.+)\\\\"") elseif CAP1 ~= nil and string.sub(CAP1,1,1) ~= ""#"" and string.len(DESTDIR) and CAP2 ~= nil then REPLACETO=DESTDIR..""\\\\|""..CAP2 end; cond(CAP1 ~= nil and CAP2 ~= nil and string.len(CAP1) and string.len(CAP2) and string.sub(CAP1,1,1) ~= ""#"" and string.len(REPLACETO), REPLACETO)",0,0,1,0,1

Result:

|aaa bbb ccc
#> d:\dirA\ddd
d:\dirA\|aaa bbb ccc
#> d:\dirC\ddd
d:\dirC\|bbb

Additionally, the first line should not be replaced, because REPLACETO is empty, but anyway it does replacement.

Capture variables does not reset

Example:

# dest: "d:\blabla"
#> c:\test1\|test1.txt.lnk
D:\test test\test1.txt
#> c:\test2\test2.txt.lnk
D:\test test\|test2.txt

Find what:

^([^\r\n\|]+)(?:\|([^\r\n\|]+)(?:\|([^\r\n\|]+)(?:\|([^\r\n\|]+))?)?)?

Replace with:

init({DESTDIR="",REPLACETO=""}); 

if CAP1 ~= nil and string.sub(CAP1,1,3) == "#> " then
  if CAP2 ~= nil and string.len(CAP2) > 0 then
    DESTDIR=string.match(string.sub(CAP1,4,-1),"^(.+)")
  else
    DESTDIR=string.match(string.sub(CAP1,4,-1),"^(.+\\\\)")
  end;
elseif CAP1 ~= nil and string.sub(CAP1,1,1) ~= "#" and DESTDIR ~= nil and string.len(DESTDIR) > 0 and CAP2 ~= nil then
  REPLACETO=DESTDIR.."|"..CAP2 
else
  REPLACETO=nil 
end; 

cond(CAP1 ~= nil and CAP2 ~= nil and string.len(CAP1) > 0 and string.len(CAP2) > 0 and string.sub(CAP1,1,1) ~= "#" and REPLACETO ~= nil and string.len(REPLACETO) > 0, REPLACETO)

[x] Use Variables
Search Mode: Regular expression
[x] Use List

Result:

# dest: "d:\blabla"
#> c:\test1\|test1.txt.lnk
c:\test1\|test1.txt.lnk
#> c:\test2\test2.txt.lnk
c:\test2\test2.txt.lnk|test2.txt

Expectation:

# dest: "d:\blabla"
#> c:\test1\|test1.txt.lnk
c:\test1\|test1.txt.lnk
#> c:\test2\test2.txt.lnk
c:\test2\|test2.txt

If try to change the code to lookup the CAP2:

init({DESTDIR="",REPLACETO=""}); 

if CAP1 ~= nil and string.sub(CAP1,1,3) == "#> " then
  if CAP2 ~= nil and string.len(CAP2) > 0 then
    DESTDIR=string.match(string.sub(CAP1,4,-1),"^(.+)")..";"..CAP2..";"
  else
    DESTDIR=string.match(string.sub(CAP1,4,-1),"^(.+\\\\)")
  end;
elseif CAP1 ~= nil and string.sub(CAP1,1,1) ~= "#" and DESTDIR ~= nil and string.len(DESTDIR) > 0 and CAP2 ~= nil then
  REPLACETO=DESTDIR.."|"..CAP2 
else
  REPLACETO=nil 
end; 

cond(CAP1 ~= nil and CAP2 ~= nil and string.len(CAP1) > 0 and string.len(CAP2) > 0 and string.sub(CAP1,1,1) ~= "#" and REPLACETO ~= nil and string.len(REPLACETO) > 0, REPLACETO)

Result:

# dest: "d:\blabla"
#> c:\test1\|test1.txt.lnk
c:\test1\;test1.txt.lnk;|test1.txt.lnk
#> c:\test2\test2.txt.lnk
c:\test2\test2.txt.lnk;test1.txt.lnk;|test2.txt

Expectation:

# dest: "d:\blabla"
#> c:\test1\|test1.txt.lnk
c:\test1\;test1.txt.lnk;|test1.txt.lnk
#> c:\test2\test2.txt.lnk
c:\test2\test2.txt.lnk;;|test2.txt

As you see CAP2 must be nil as there is no expression to match (has no | character), but the parser leaves CAP variables from a previous match.

And seems I can not reset CAP variables. These won't work:

init({DESTDIR="",REPLACETO=""}); 

if CAP1 ~= nil and string.sub(CAP1,1,3) == "#> " then
  if CAP2 ~= nil and string.len(CAP2) > 0 then
    DESTDIR=string.match(string.sub(CAP1,4,-1),"^(.+)")..";"..CAP2..";"
  else
    DESTDIR=string.match(string.sub(CAP1,4,-1),"^(.+\\\\)")
  end; 
elseif CAP1 ~= nil and string.sub(CAP1,1,1) ~= "#" and DESTDIR ~= nil and string.len(DESTDIR) > 0 and CAP2 ~= nil then
  REPLACETO=DESTDIR.."|"..CAP2 
else
  REPLACETO="" 
end; 

cond(CAP1 ~= nil and CAP2 ~= nil and string.len(CAP1) > 0 and string.len(CAP2) > 0 and string.sub(CAP1,1,1) ~= "#" and REPLACETO ~= nil and string.len(REPLACETO) > 0, REPLACETO); 

if CAP1 ~= nil and string.sub(CAP1,1,1) ~= "#" then
  CAP2=nil 
end;  

Result:

# dest: "d:\blabla"
#> c:\test1\|test1.txt.lnk
c:\test1\;test1.txt.lnk;|test1.txt.lnk
#> c:\test2\test2.txt.lnk
c:\test2\test2.txt.lnk;test1.txt.lnk;|test2.txt

Make Escape key close smarter

If the dialog is just opened as a floating window, Escape key should - and currently does - close the floating dialog window. If however the dialog is docked to the Notepad++ window in one of the four (top, bottom, left, or right) docking spots, Escape key should not close the dialog; rather, it should set focus to the current Scintilla editing component. The thought is if the dialog is docked, the user may want to use it multiple times while swapping back and forth to navigate through the document.

Replace using Capture Variables

Trying to renumber the ini keys from #31 with new syntax:

Find what:

^(button|cmd|param|path|iconic|menu)\d*=

Replace with:

init({BTTNCNT=0}); if "$1" == "button" then BTTNCNT=BTTNCNT+1 end; set("$1"..BTTNCNT.."=")

But it does not seem to work.

The set always returns .0=.

Execution halted

Have the file:

# dest: "d:\blabla"
#> c:\myshortcuts1\|test1.txt.lnk
e:\blabla\|test1.txt
#> c:\myshortcuts2\|test2.txt.lnk
e:\blabla\|test2.txt

Want to replace to:

# dest: "d:\blabla"
#> c:\myshortcuts1\|test1.txt.lnk
c:\myshortcuts1\|test1.txt
#> c:\myshortcuts2\|test2.txt.lnk
c:\myshortcuts2\|test2.txt

The expression:

Selected,Find,Replace,WholeWord,MatchCase,UseVariables,Regex,Extended
1,"^([^\\r\\n\\|]+)(\\|([^\\r\\n\\|]+)(?:\\|([^\\r\\n\\|]+)(?:\\|([^\\r\\n\\|]+))?)?)?","init({DESTDIR=""""}); if CAP1 ~= nil and string.sub(CAP1,1,2) == ""#>"" then DESTDIR=string.sub(CAP1,4,-1) elseif CAP1 ~= nil and string.len(DESTDIR) and CAP2 ~= nil then set(DESTDIR..""|""..CAP2) end",0,0,1,0,1

Result:

---------------------------
Use Variables: Execution Error
---------------------------
Execution halted due to execution failure in:

init({DESTDIR=""}); if CAP1 ~= nil and string.sub(CAP1,1,2) == "#>" then DESTDIR=string.sub(CAP1,4,-1) elseif CAP1 ~= nil and string.len(DESTDIR) and CAP2 ~= nil then set(DESTDIR.."|"..CAP2) end
---------------------------
OK   
---------------------------

Can you help with the expression?

Build issue from command line

When using standard msbuild from command line, getting:

notepadpp-multireplace\src\AboutDialog.cpp(ROW,COL): error C2065: 'IDC_***': undeclared identifier

type errors. Due to missing:

#include "DockingFeature/resource.h"

in 'src\AboutDialog.cpp'.

Also, getting:

src\MultiReplace.h(20,10): fatal error C1083: Cannot open include file: 'resource.h': No such file or directory

due to incorrect include, should be:

#include "DockingFeature\resource.h"

32-bit build warning as error signed mismatch (again)

Some new updates have reintroduced an old warning as error again:

notepadpp-multireplace\src\MultiReplace.cpp(2143,23): warning C4018: '<': signed/unsigned mismatch

notepadpp-multireplace\src\MultiReplace.cpp(2143,23): error C2220: the following warning is treated as an error 

Due to line:

    for (int i = 0; i < replaceListData.size(); i++) {

Guessing replaceListData.size() is of size_t.

Cheers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.