• Did I break NPP?

    17
    0 Votes
    17 Posts
    783 Views
    Lycan ThropeL

    @alan-kilborn ,

    Thanks. I appeciated, and actually understood the information you were linking me to. I guess my humorous response wasn’t taken the way it was intended, so… sorry . :-)

    But I definitely agree with your observation, that indeed, it is not at all obvious, which is kind of why my answer was a “flippant” so I apologize if you didn’t understand that I was agreeing with you. :-)

    Lee

  • Issue with making this (^.*\\.dxy$)|

    4
    0 Votes
    4 Posts
    247 Views
    Juan FranciscoJ

    This is what I have my couple ones from many more. Thank you. Now i know something. Still learning regular expression. And knowing what each means.

    92dfc47b-10df-4feb-908b-8a781b625997-image.png

  • I would like to do my own PowerShell Indenting

    7
    0 Votes
    7 Posts
    3k Views
    Michael VincentM

    @michael-vincent said in I would like to do my own PowerShell Indenting:

    Feel free to experiment with this and see if you can get it to work AFTER Notepad++ does it’s auto-indenting-of {.

    @mmannion
    @Steve-Almes
    @Alan-Kilborn
    @PeterJones

    I think I got it working by calling 2 callbacks (CHARADDED and UPDATEUI) instead of just CHARADDED. The following works for my when I type:

    if (test) [ENTER]

    I get:

    if (test) |

    Where | is cursor. Then I type the { and get this:

    if (test) {|}

    Where | is cursor. The { auto-inserts the closing } and both are auto-indented 4-spaces as requested. Pressing Enter now yeilds:

    if (test) { | }

    Obviously you can adjust the _set_indent() function to perform how you want.

    from Npp import editor, notepad, LANGTYPE, NOTIFICATION, SCINTILLANOTIFICATION class GnuIndent(object): def __init__(self): self.DEBUG = False self.ENABLED = False self.my_language = [LANGTYPE.POWERSHELL] self.is_my_language = False self._do_indent = False self.nppCallbacks = { self._on_buffer_activated: [NOTIFICATION.BUFFERACTIVATED, NOTIFICATION.LANGCHANGED] } self.edCallbacks = { self._on_charadded: [SCINTILLANOTIFICATION.CHARADDED], self._on_updateui: [SCINTILLANOTIFICATION.UPDATEUI] } def start(self): """Start the service""" for cb in self.nppCallbacks: notepad.callback(cb, self.nppCallbacks[cb]) for cb in self.edCallbacks: editor.callbackSync(cb, self.edCallbacks[cb]) self.ENABLED = True def status(self): """Status the service""" for e in sorted(self.__dict__): print("{0:<25} : {1}".format(e, self.__dict__[e])) def stop(self): """Stop the service""" for cb in self.nppCallbacks: notepad.clearCallbacks(cb) for cb in self.edCallbacks: editor.clearCallbacks(cb) self.ENABLED = False def _on_buffer_activated(self, args): lang = notepad.getCurrentLang() if lang in self.my_language: self.is_my_language = True else: self.is_my_language = False def _on_charadded(self, args): if not self.is_my_language: return if chr(args['ch']) == '{': self._do_indent = True def _on_updateui(self, args): if not self.is_my_language: return if args['updated'] & 0x01 and self._do_indent: self._do_indent = False self._set_indent() def _set_indent(self): tabwidth = editor.getTabWidth() pos = editor.getCurrentPos() currline = editor.lineFromPosition(pos) indent = editor.getLineIndentation(currline - 1) if self.DEBUG: print(pos, currline, indent, tabwidth) editor.setLineIndentation(currline, indent + tabwidth) if __name__ == '__main__': gnuIndent = GnuIndent() gnuIndent.start()
  • 0 Votes
    3 Posts
    552 Views
    A

    @peterjones Thanks a lot! did the job better

  • Many times, colors disappear

    5
    0 Votes
    5 Posts
    528 Views
    PeterJonesP

    @kenhorse2 ,

    Almost everyone here is just a fellow user of Notepad++ (hence the name “Notepad++ Community”, not “Notepad++ Paid Support”). Thus, if we haven’t seen your problem, or don’t have ideas on how to debug it, there’s not much we can do. And you haven’t given us much to go on: presumably, anyone here who does use PHP regularly hasn’t seen a 10% failure rate of the PHP lexer. Which means likely, the problem is on your end, or very rare for the vast majority of users.

    if you gave us more information (maybe an example PHP file that shows the problem for you), there might be more for us to work with.

    You could try turning off plugins: rename c:\notepad++\plugins\ folder to c:\notepad++\xplugins temporarily, or run notepad++ with the -noPlugin command line option to see if the problem goes away. If either of these work, then one of your plugins is causing the problem.

    You could try seeing if the same thing happens with the default theme instead of the ruby blue theme – maybe there’s some setting in the theme that sometimes confuses Notepad++.

  • PythonScript

    30
    0 Votes
    30 Posts
    2k Views
    Heinz Berecz 0H

    @alan-kilborn said in PythonScript:

    The recommended standard for Python is to insert 4 spaces every time the Tab key is pressed.
    If you must deviate from that standard, UGH, you go into the Settings > Preferences… > Language > Tab Settings > python and change it to what you want:

    Thank you very much.

  • Search and replace "" with " in random hyperlinks in a csv file

    8
    0 Votes
    8 Posts
    855 Views
    Waqas SaeedW

    @alan-kilborn Thank you for your help. My problem has solved. I am grateful.

  • 0 Votes
    2 Posts
    223 Views
    gstaviG

    It sounds as if you want Notepad++ to help you circumvent your company policies.
    If Notepad++ could save directly into some cloud (which ?), wouldn’t it become a forbidden cloud storage provider?

    Notepad++ is designed to work with a file system. It uses file system API. It doesn’t even know if the file system is local or over network.
    The majority of users that want cloud synching just use the cloud synching software so your feature request is serves a fraction of the user base.
    It is far more likely that you could convince your company of your need then Notepad++ will add such a feature.

  • UDL based on default HTML

    3
    0 Votes
    3 Posts
    321 Views
    SEE-ICTS

    @ekopalypse Thanks for the quick reply. I’m not sure that the additional functionality would justify the work required to implement it. I’ll take a look and see. At least I’ll learn something about lexers!

  • Something like "negative" search?

    4
    0 Votes
    4 Posts
    1k Views
    H

    @ekopalypse said in Something like "negative" search?:

    ^(?!.this_is_not_included).

    Thx for your reply. Unfortunatly that seems not to work. I will look into the thread you mentioned.

  • Regex: Show the string result from searching ALL FILES, between 2 parts

    12
    0 Votes
    12 Posts
    465 Views
    Alan KilbornA

    @neil-schipper said in Regex: Show the string result from searching ALL FILES, between 2 parts:

    copy text from Search Results (pane or window) into this new file.

    There are 2 ways to do this, depending on whether or not you need information about the files to carry over in the copy.

    This method will get you the search/file/line info along with the lines-of-match:

    2d688ece-d6dd-48c3-81ef-eb905e23b8f0-image.png

    will get:

    Search "t" (2 hits in 1 file of 1 searched) new 1 (2 hits) Line 1: (?s)(?!.*this_is_not_included).* Line 1: (?s)(?!.*this_is_not_included).*

    This method will get you only the line data of the match:

    bbd8a609-ea09-4faf-b9d4-ce4d9a871158-image.png

    will get:

    (?s)(?!.*this_is_not_included).*

    Note that in the second example, since there are 2 results but the matched lines are the same line, only ONE copy of the line data is put into the clipboard.

  • Pythonscript hidelines()

    14
    0 Votes
    14 Posts
    702 Views
    Paul WormerP

    @alan-kilborn
    I thank you and the others in this thread for their patient advice. To show what I did with it, I copy my script and sample input.

    """ Hide entries in a diary. - Daily entries are preceded by an empty line followed by the date on a single line. - Dates can be either in American or in European format. - Days occur with irregular intervals. """ from __future__ import print_function # Python 2.7 from Npp import * def getStartPositionNextLine(pos): """ Get start position of line below line of `pos`. Note that positions in scripts start at 0 whereas the statusline gives a position starting at 1. """ rpos = editor.getLineEndPosition(editor.lineFromPosition(pos)) + 2 #skip \r\n return rpos def getEndPositionPreviousLine(pos): rpos = editor.getLineEndPosition(editor.lineFromPosition(pos)-1) return rpos regex = r'^\d{1,2}(-|/)\d{1,2}(-|/)\d{4}?' # European or American date lenFile = editor.getLength() # Find start and end position of first date string: startDate, endDate = editor.findText(FINDOPTION.REGEXP, 0, lenFile, regex) startSel = getStartPositionNextLine(endDate) editor.setSelectionStart(startSel) while endDate < lenFile: startDate0, endDate0 = startDate, endDate try: startDate, endDate = editor.findText(FINDOPTION.REGEXP, endDate0, lenFile, regex) except: break else: # Go back 2 lines skipping empty line: endSel = getEndPositionPreviousLine(getEndPositionPreviousLine(endDate)) editor.setSelectionEnd(endSel) notepad.menuCommand(MENUCOMMAND.VIEW_HIDELINES) # New selection starts at line below date line: startSel = getStartPositionNextLine(endDate) editor.setSelectionStart(startSel) editor.setSelectionEnd(lenFile) notepad.menuCommand(MENUCOMMAND.VIEW_HIDELINES)

    A sample diary:

    DE BELLO GALLICO 3-1-2019 Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi omnes lingua, institutis, legibus inter se differunt. Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit. Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe commeant atque ea quae ad effeminandos animos pertinent important, proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter ellum gerunt. 7/6/2019 Qua de causa Helvetii quoque reliquos Gallos virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt. Eorum una pars, quam Gallos obtinere dictum est, initium capit a flumine Rhodano, continetur Garumna flumine, Oceano, finibus Belgarum, attingit etiam ab Sequanis et Helvetiis flumen Rhenum, vergit ad septentriones. Belgae ab extremis Galliae finibus oriuntur, pertinent ad inferiorem partem fluminis Rheni, spectant in septentrionem et orientem solem. Aquitania a Garumna flumine ad Pyrenaeos montes et eam partem Oceani quae est ad ispaniam pertinet; spectat inter occasum solis et septentriones. 10/9/2019 (ibidem) Apud Helvetios longe nobilissimus fuit et ditissimus Orgetorix. Is M. Messala, M. Pisone consulibus regni cupiditate inductus coniurationem nobilitatis fecit et civitati persuasit ut de finibus suis cum omnibus copiis exirent: perfacile esse, cum virtute omnibus praestarent, totius Galliae imperio potiri. Id hoc facilius iis persuasit, quod undique loci natura Helvetii continentur : una ex parte flumine Rheno latissimo atque altissimo, qui agrum elvetium a Germanis dividit; altera ex parte monte Iura altissimo, qui est inter Sequanos et Helvetios; tertia lacu Lemanno et flumine odano, qui provinciam nostram ab Helvetiis dividit. 22-12-2019 His rebus fiebat ut et minus late vagarentur et minus facile finitimis bellum inferre possent; qua ex parte homines bellandi cupidi agno dolore adficiebantur. Pro multitudine autem hominum et progloria belli atque fortitudinis angustos se fines habere arbitrabantur, qui in longitudinem milia passuum CCXL, in latitudinem CLXXX patebant.
  • multiple search and remove

    14
    0 Votes
    14 Posts
    5k Views
    guy038G

    Hello, @handa-flocka, @peterjones, @alan-kilborn and All,

    Just tried your script, Peter and it wokrs like a charm ! Of course, the list of strings can be displayed in any order !

    Now, regarding your attempt to find a previous script, on this topic, maybe it could be related to this @ekopalypse’s script :

    https://community.notepad-plus-plus.org/post/57173

    and the @alan-kilborn’s subsequent modification :

    https://community.notepad-plus-plus.org/post/57229

    Changes are, of course, needed to fit this present topic !

    BR

    guy038

  • Format data for CSV

    2
    0 Votes
    2 Posts
    645 Views
    Michael VincentM

    @marissa-stradley

    Record a macro.

    Put cursor before the “39” Macro => Start Recording Press the Shift key and press the down arrow 10 times (so that you’ve highlighted the lines from “39” to the blank line before “40”) Edit => Line Operations => Join Lines Press the down arrow and Home key so the cursor is now in front of the “40”. Macro => Stop Recording

    Now use the Macro => Run a Macro Multiple Times… menu entry to finish the file.

    Cheers.

  • Weird regex mode searching in normal search mode

    7
    2 Votes
    7 Posts
    359 Views
    EkopalypseE

    @alan-kilborn

    the SCI_SETSEARCHFLAGS might be the culprit.
    But I haven’t done any tests, I must say.

  • Counting up a number that is part of a line

    5
    0 Votes
    5 Posts
    480 Views
    Cirlot123456C

    @ekopalypse thanks I worked it out now, this is gonna be immensely useful in the future :)

  • Does N++ have Auto-Scrolling?

    3
    0 Votes
    3 Posts
    1k Views
    artie-finkelsteinA

    @luis-piña-iii

    The MMB is not a scroll button, but can be made into one with XMBC. Please note this application is outside the subject purview of this community and any support must come from the XMBC community (there is one).

  • Search - Retained ? ? ?

    8
    0 Votes
    8 Posts
    637 Views
    artie-finkelsteinA

    @kendall-demott

    Based on my current workflow, I will create a “phrase file” to store boiler plate or frequently needed text for a project. I drag the tab to the far left and leave that file loaded as I merrily edit other files. The far left tab is easy to jump to using the Window menu selection. Then it’s just a case of jump to tab, copy text, jump back to context (current) tab and execute the search and paste the copied test into the search menu. Admittedly, returning to the context (current) tab is not always easy if I have many files open. By using session files (or just relying on the built in session manager), the phrase file becomes part of the project. This approach may be a bit crude, but I can easily modify it as the tasks change.

    There are plugins that also handle things like this (quips, boiler plate, etc.), I just haven’t found one I liked enough to really learn how to use it and change my eclectic workflows appropriately.

  • How create UDL by defined/default langunge(PHP)?

    5
    0 Votes
    5 Posts
    518 Views
    WinterSilenceW

    @ekopalypse hm… as I see, PHP and JS have common code to folding blocks, but array folding doesn’t work in PHP files.

  • Automatically scrolling to caret

    6
    0 Votes
    6 Posts
    473 Views
    Alan KilbornA

    Actually, this seems to do it:

    editor.setFirstVisibleLine(editor.visibleFromDocLine(editor.lineFromPosition(editor.getCurrentPos())))