• C function exploration

    4
    1 Votes
    4 Posts
    2k Views
    Scott SumnerS

    @Telis-Tnilit

    So…not sure if the TagsView plug-in met your need, but I modified something I already had scripted (in Pythonscript) to do what you want , albeit in a basic way: The script needs to see the enclosing C function braces ( { and } ) in column 1, and when it does it takes the single line above the { as the function signature.

    So for a C function like this:

    void test2(void) { x = 1; if (1) { x = 2; } }

    when the caret is inside the function body, the status bar will show this:

    Imgur

    I call the script CFunctionShowInStatusBar.py :

    def CFSISB__callback_sci_UPDATEUI(args): def sb_print(x): if len(x) == 0: x = ' ' # writing '' to status bar does nothing, so change it! notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, x) if notepad.getCurrentFilename().lower().endswith('.c'): f = editor.findText(FINDOPTION.REGEXP, editor.getCurrentPos(), 0, '^[{}]') if f != None: (found_start_pos, found_end_pos) = f if '{' == editor.getTextRange(found_start_pos, found_end_pos): line_nbr = editor.lineFromPosition(found_start_pos) if line_nbr == 0: sb_print('not in function?') else: sb_print('in function: ' + editor.getLine(line_nbr - 1).rstrip()) else: sb_print('not in function') else: sb_print('not in function!') else: sb_print('') editor.callback(CFSISB__callback_sci_UPDATEUI, [SCINTILLANOTIFICATION.UPDATEUI])```
  • Replace all places of text that contain ips in brackets with nothing

    Locked
    10
    1 Votes
    10 Posts
    4k Views
    guy038G

    Hi, @patrick-tamm, @claudia-frank and @scott-sumner,

    Claudia, regarding your last regex, it would better to use a lazy quantifier, just in case of lines, as below :

    This is [an example] of text with [some pairs] of square brackets, in the [same line] !

    So a correct regex S/R should be :

    SEARCH : \[.*?\]

    REPLACE : []

    OPTIONS : Regular expression and Wrap around and, maybe, . matches newline if brackets pair are split on two different lines !

    ACTION : Click on the Replace All button

    Cheers,

    guy038

  • Show count of occurrences of a selected string

    Locked
    2
    0 Votes
    2 Posts
    5k Views
    Scott SumnerS

    @bob-bob

    You could do a plugin to get this behavior, or you could script it. Here’s an example (may not be fully rounded out) in Pythonscript, I call it SelectedTextCountIntoStatusBar.py; you would run it once per Notepad++ session:

    def callback_sci_UPDATEUI(args): if args['updated'] & UPDATE.SELECTION: matches = [] if editor.getTextLength() < 100000: # don't search "big" files if editor.getSelections() == 1 and not editor.getSelectionEmpty(): try: editor.research(r'\Q' + editor.getSelText() + r'\E', lambda m: matches.append(1)) except: matches = [] l = len(matches) notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, ' ' if l == 0 else '{} occurrence(s) of selected text'.format(l)) editor.callback(callback_sci_UPDATEUI, [SCINTILLANOTIFICATION.UPDATEUI])
  • 2 Votes
    32 Posts
    14k Views
    Marco CzenM

    @Scott-Sumner - Noted. Thanks.

  • How to replace a whole line starting with a given expression

    Locked
    5
    0 Votes
    5 Posts
    30k Views
    guy038G

    Hello @rachad-antonius, @claudia-frank, @Scott-sumner, and All,

    Claudia, don’t forget that the \s regular syntax matches any single character of the range [\t\n\x0B\f\r\x20\x85\xA0\x{2028}\x{2029}]

    So let’s imagine this initial text, below :

    Which begins with 3 empty lines

    With 2 other empty lines, after line bbbbbbb

    And the second to last line contains, ONLY the expression GIVEN_WORD

    GIVEN_WORD aaaaaaaaaaaa bbbbbbb GIVEN_WORD ccccccccc GIVEN_WORDeeeeeeeeeeeeeeeee GIVEN_WORD fffffff gggggggggggggggggg hhhhhhhhh GIVEN_WORD iiiiiiiiiiiiiiiiiiiiiiiiiiiii GIVEN_WORD jjjjjjjjjjjjjjjjjjjjjj

    With your regex, ^\s*GIVEN_WORD.*, this text turns into :

    bbbbbbb gggggggggggggggggg hhhhhhhhh jjjjjjjjjjjjjjjjjjjjjj

    Whereas the Scott’s regex, (?-s)^GIVEN_WORD.*\R gives :

    bbbbbbb gggggggggggggggggg hhhhhhhhh jjjjjjjjjjjjjjjjjjjjjj

    This later syntax seems more correct as it matches a single line, at a time ;-)) doesn’t it ? Claudia, you may click several times on the couple Find Next | Replace, with the View > Show Symbol > Show All Characters option set !

    BTW, @rachad-antonius, the \R syntax, at the end of the regex, matches the line-break characters of the current line, whatever the kind of file ( Unix, Windows, or Mac ) !

    Additional Notes :

    In case, @rachad-antonius, that you would like, in addition, to delete entire lines, having some blank characters ( spaces and/or tabulations ), before the GIVEN_WORD, you could use the regex ^\h*GIVEN_WORD(?-s).*\R

    Secondly , depending if you prefer the GIVEN_WORD to be matched with that exact case, or not, you could choose :

    The regex ^\h*(?-i)GIVEN_WORD(?-s).*\R for an exact case match

    The regex ^\h*(?i)GIVEN_WORD(?-s).*\R for a match, independent of the case of GIVEN_WORD

    Finally, if GIVEN_WORD represents an complete expression, containing special regex characters, I advice you to use the following one : ^\h*(?-i)\QGIVEN_WORD\E(?-s).*\R. Indeed, between the 2 syntaxes \Q and \E, you may insert any character or symbol, without no restriction !!

    Refer to :

    http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.quoting_escape

    For instance, if you want to delete the entire lines, beginning with the string +++ | Test | +++, whatever the case of the word test, and possibly preceded, in the same line, by some blank characters, use the regex, below :

    ^\h*(?i)\Q+++ | Test | +++\E(?-s).*\R

    Remark :

    If you don’t use the quoted form \Q.......\E, the regex must be rewritten as below, which each special regex character escaped with an \ character !

    ^\h*(?i)\+\+\+ \| Test \| \+\+\+(?-s).*\R

    Best Regards,

    guy038

    P. S. :

    Claudia, many Thanks for your Xmas Greetings ! Sorry for not replying, in time :-< I just forgot to consult my e-mail box ;-))

  • 0 Votes
    7 Posts
    10k Views
    Marco CzenM

    Thats ;

    C:\Users\username\AppData\Roaming\Notepad++

  • Issue when trying to overwrite a closing brace on notepad++

    Locked
    6
    0 Votes
    6 Posts
    2k Views
    Scott SumnerS

    @CodeSteady said:

    do you have a solution?

    Instead of pressing } just press right-arrow (or End) to move beyond the auto-inserted closing brace? :-)

  • Big encoding problem with UTF-8 / UTF-8-BOM / ANSI / ISO-8859-1

    4
    0 Votes
    4 Posts
    4k Views
    Sybell LirwacoS

    Unfortunately the problem with 7.5.1 is not solved.
    npp.7.5.1.bin.minimalist.x64 opens files stored in UTF-8 containing characters from the Mathematical Alphanumeric Symbols Unicode block as ANSI.

    What I have just seen is that the term “ANSI” means different. Once the term ANSI means Windows-1252 (Menubar -> Encoding) and once means only ISO-8859-1 (Preferences -> New Document -> Encoding). Or there are problems because files stored in Windows-1252 are opened as ANSI, even if “Apply to opened ANSI file” is set.

  • Find and Replace with RegEx help

    Locked
    9
    0 Votes
    9 Posts
    4k Views
    Ksomeone MsomeoneK

    @Claudia-Frank said:

    @guy038

    I was close, wasn’t I? :-D

    thx for the detailed information and improvements - always a pleasure :-)

    Cheers
    Claudia

    Yours was the one I used before guy038 made his post and it worked perfectly, so I would say you were more than close. :)

  • Red console

    2
    0 Votes
    2 Posts
    1k Views
    Claudia FrankC

    @Ivo-Balbaert

    I don’t know Red console - could it be that it closes while providing incorrect data to it,
    like a file which isn’t found?
    Can you run Red console without providing a file as parameter from notepad++ run menu?
    Another option might be to use cmd /k in front of red…exe - maybe you see the error it throws
    or why it is closing.

    Cheers
    Claudia

  • Line Number

    9
    0 Votes
    9 Posts
    3k Views
    gstaviG

    The end of line is screwed, probably something like <CR><LF><LF>, Notepad++ sees every line as a line + blank line.
    So Line number in Notepad++ is multiplied by 2.

  • 请让这款优秀的编辑器支持MAC OS X

    Locked
    2
    0 Votes
    2 Posts
    2k Views
    Meta ChuhM

    your “general voice of the public” about an incompatible subject will probably not be understood, if you use an incompatible language to try to transport your incompatible wishes.

  • Quick database rip

    Locked
    3
    0 Votes
    3 Posts
    1k Views
    guy038G

    Hello @xavier-xenoph,

    It’s not very clear what you want to achieve, but, to my mind, you would like to change all records of your database file :

    IPHERE | DATE: | HWID: | password: | audioid: | hashid : |

    as :

    | hashid : |

    Am I right about it ?

    If so :

    Open your database file, in N++

    Open the Replace dialog ( Ctrl + H )

    SEARCH (?-s)^.+(?=\|.+\|$)

    REPLACE Leave EMPTY

    OPTIONS Wrap around and Regular expression ticked

    ACTION Click on the Replace All button

    Notes :

    As usual, the (?-s) modifier means that the dot ( . ) matches a standard character, ONLY and NOT any *line-break character

    Then the part ^.+ represents the longest range of characters of any line, but…

    ONLY IF the condition, in the look-ahead, ( (?=\|.+\|$) ) is true. That is to say if it’s followed by two | symbols, with some characters between, ( \|.+\| ), which end each line ( $ )

    Note that the | symbol have to be escaped as \|, to be interpreted as literal, as it’s a special regex character, too !

    Due to the empty replacement zone, the selected range, of each line, is simply deleted

    Best Regards,

    guy038

  • Problem with CSS padding/margin

    Locked
    2
    0 Votes
    2 Posts
    1k Views
    Scott SumnerS

    @tomass1047

    Sorry, dude, this is not the right place to discuss that.
    This Community is for Notepad++ - related discussion.
    Good luck in your quest for answers–somewhere else.

  • Tooltips on toolbar icons

    Locked
    2
    0 Votes
    2 Posts
    1k Views
    dailD

    There’s no way to turn it off or on, just shows it by default.

  • Create a share button?

    Locked
    2
    0 Votes
    2 Posts
    978 Views
    Scott SumnerS

    @אודי-יהודה-אברג’ל

    You are really asking that in the WRONG PLACE. Sorry.

  • How to achieve <bold>selection</bold>?

    Locked
    10
    1 Votes
    10 Posts
    8k Views
    guy038G

    Hello @liuruiqi1993 and All,

    BTW, I advice you to downgrade to the v7.5.1 version of Notepad++, because there are some encoding issues with the last two N++ versions ! See below :

    https://notepad-plus-plus.org/community/topic/14936/update-to-7-5-3-file-encode-wrong/2

    Now, I understand why it did,'t work with your old 5.9.4 version. Just because, since the N++ v.6.0 version, a new search engine is implemented, with the Perl Common Regular Expressions feature, of the Boost C++ regex library ! This new search engine allows you to run complicated S/R, once you’re acquainted with Regular expressions language :-))

    For newby people, about regular expressions concept and syntax, begin with that article, in N++ Wiki :

    http://docs.notepad-plus-plus.org/index.php/Regular_Expressions

    In addition, you’ll find good documentation, about the Boost C++ Regex library, v1.55.0 ( similar to the PERL Regular Common Expressions, v5.8 ), used by Notepad++, since its 6.0 version, at the TWO addresses below :

    http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html

    http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html

    The FIRST link explains the syntax, of regular expressions, in the SEARCH part

    The SECOND link explains the syntax, of regular expressions, in the REPLACEMENT part

    You may, also, look for valuable informations, on the sites, below :

    http://www.regular-expressions.info

    http://www.rexegg.com

    http://perldoc.perl.org/perlre.html

    Be aware that, as any documentation, it may contain some errors ! Anyway, if you detected one, that’s good news : you’re improving ;-))

  • Complex regex substitution

    8
    0 Votes
    8 Posts
    3k Views
    Simone SpinozziS

    @cipher-1024

    it’s not json and the tabs are just there to allow spacing so that they “look good” on a single line when a bunch of them are all there at the same time. (basically they line up stuff vertically… and yes… that sounds idiotic… but i did not write the original “code” 😅) It cannot be on multiple lines as the intepreter of the code sees every new line as a different “item”. I did not write the interpreter, i’m just trying to help modify a bunch of items at the same time. Thus i cannot change the writing “language”. The task was to learn how to change multiple instances of similar things all at once so that in the future these things can be changed easily.
  • Matlab cell mode highlight mechanism

    5
    0 Votes
    5 Posts
    3k Views
    Ms NM

    I think you are right. I will give the function list method a go.
    https://notepad-plus-plus.org/features/function-list.html

  • extended character search suddenly not working.

    Locked
    2
    0 Votes
    2 Posts
    1k Views
    Scott SumnerS

    @Mark-Gould

    Maybe you are just doing it wrong. But since you didn’t tell us what you are doing, no one can make a judgment. :-(

    Maybe check this thread for generic troubleshooting tips?