• Moving blocks along with content

    Locked
    15
    0 Votes
    15 Posts
    4k Views
    andrecool-68A

    @rddim It works, but when a block consists of a very large number of lines … it is not very convenient to do (visually you can lose the beginning and end of the block)

  • Notepad++ will not open any file

    Locked
    2
    0 Votes
    2 Posts
    460 Views
    EkopalypseE

    @Yurk-Huntz
    have you checked that your registry entries are correct?
    If you are using the zipped version, how did you register the shell extension?

  • Pythonscript plugin, how to insert console code into the startup script?

    Locked
    3
    0 Votes
    3 Posts
    573 Views
    SalviaSageS

    Yes, that worked.
    Thank you.

  • Assign Language by Line

    23
    0 Votes
    23 Posts
    12k Views
    EkopalypseE
    # -*- coding: utf-8 -*- from Npp import editor, notepad, INDICATORSTYLE, INDICFLAG, LANGTYPE, NOTIFICATION import xml.etree.ElementTree as et import os import json from pprint import pformat try: TextStyler().register_document() except NameError: SC_INDICVALUEBIT = 0x1000000 INDICATOR_ID = 8 class SingletonTextStyler(type): ''' Ensures, more or less, that only one instance of the main class can be instantiated ''' _instance = None def __call__(cls, *args, **kwargs): if cls._instance is None: cls._instance = super(SingletonTextStyler, cls).__call__(*args, **kwargs) return cls._instance class TextStyler(object): __metaclass__ = SingletonTextStyler def __init__(self): self.hidden_scintilla = notepad.createScintilla() editor1.indicSetStyle(INDICATOR_ID, INDICATORSTYLE.TEXTFORE) editor1.indicSetFlags(INDICATOR_ID, INDICFLAG.VALUEFORE) editor2.indicSetStyle(INDICATOR_ID, INDICATORSTYLE.TEXTFORE) editor2.indicSetFlags(INDICATOR_ID, INDICFLAG.VALUEFORE) self.npp_config_dir = notepad.getNppDir() self.styler_dict = dict() self.active_theme = et.parse(self.get_active_styler_xml()) # self.udls = self.create_udls_xml() self.lexer_keywords = self.get_langs_xml() self.list_of_document_ids = [] self.current_lexer = 'null' self.default_id = 0 self.memory_file = os.path.join(notepad.getPluginConfigDir(), 'TextStylerMemory.txt') self.remember_styles = None notepad.callback(self.on_langchanged, [NOTIFICATION.LANGCHANGED]) notepad.callback(self.on_fileclosed, [NOTIFICATION.FILECLOSED]) notepad.callback(self.on_filesaved, [NOTIFICATION.FILESAVED]) notepad.callback(self.on_shutdown, [NOTIFICATION.SHUTDOWN]) # there is an peformance issue when calling paint_it directly, # therefore we are hacking around langchanged notification def on_langchanged(self, args): ''' Gets called by npp when language change is deteced Resets to null lexer and calls main method ''' if (args['bufferID'] in self.list_of_document_ids): if notepad.getLangType() == LANGTYPE.TXT: if self.current_lexer != 'null': self.main(self.current_lexer) else: notepad.messageBox('Expected a lexer but null found', 'Error',0) else: self.current_lexer = editor.getLexerLanguage() if self.current_lexer == 'user': self.current_lexer = notepad.getLanguageName(notepad.getLangType()) notepad.setLangType(LANGTYPE.TXT) def on_shutdown(self, args): ''' Gets called by npp when shutting down TODO: store knwon files and their colors which then would be reused on fileopen/bufferactived callback ''' notepad.destroyScintilla(self.hidden_scintilla) def on_filesaved(self, args): ''' Gets called by npp when a buffer is saved TODO: check if doc is of interest if so, get current filename check if doc is empty if so delete from memory if not store current colors and their position ''' if (args['bufferID'] in self.list_of_document_ids): current_file = notepad.getCurrentFilename() from pprint import pformat values = [editor.indicatorValueAt(INDICATOR_ID,x) for x in range(editor.getTextLength())] prev_value = 0 fill_range = 1 sorted_values = [] for offset, value in enumerate(values): if value == 0: continue if prev_value == value: fill_range += 1 else: sorted_values.append((value, offset-fill_range, fill_range)) prev_value = value fill_range = 1 print(pformat(sorted_values)) def on_fileclosed(self, args): ''' Gets called by npp when a buffer gets closed Removes unneeded buffer ids from internal list ''' if (args['bufferID'] in self.list_of_document_ids): self.list_of_document_ids.remove(args['bufferID']) def get_active_styler_xml(self): ''' returns the xml path of the current theme ''' xml_file = os.path.join(self.npp_config_dir, 'config.xml') xml_doc = et.parse(xml_file) return xml_doc.find('GUIConfigs/GUIConfig[@name="stylerTheme"]').get('path') # def create_udls_xml(self): # ''' merge all udls from userDefineLangs into one big xml ''' # udls_dir = os.path.join(self.npp_config_dir, 'userDefineLangs') # udl_files = os.listdir(udls_dir) # root = et.Element('NotepadPlus') # for udl_file in udl_files: # xml_doc = et.parse(os.path.join(udls_dir, udl_file)) # user_lang = xml_doc.find('UserLang') # root.append(user_lang) # return root def get_lexer_styles(self, lexername): ''' Creates the styling dictionary by reading the styler xml ''' if lexername.startswith('udf - '): return # as long as hidden scintilla doesn't do the styling we are done here # tag = 'UserLang[@name="%s"]/Styles/WordsStyle' % lexername[6:] # lexer_styles = self.udls.findall(tag) # self.default_id = 0 # for id, result in enumerate(lexer_styles): # fgColor = result.attrib.get('fgColor', None) # if not fgColor: # notepad.messageBox('Received unexpected value\nid: {}\nfgColor: {}'.format(id, fgColor), 'Error',0) # return # red, green, blue = bytearray.fromhex(fgColor) # color = (blue<<16) + (green<<8) + red # self.styler_dict[int(id)] = color tag = 'LexerStyles/LexerType[@name="%s"]/WordsStyle' % lexername lexer_styles = self.active_theme.findall(tag) for result in lexer_styles: if result.attrib.get('name', None) == 'DEFAULT': id = result.attrib.get('styleID', None) self.default_id = int(id) else: id = result.attrib.get('styleID', None) fgColor = result.attrib.get('fgColor', None) if not fgColor: notepad.messageBox('Received unexpected value\nid: {}\nfgColor: {}'.format(id, fgColor), 'Error',0) return red, green, blue = bytearray.fromhex(fgColor) color = (blue<<16) + (green<<8) + red self.styler_dict[int(id)] = color def get_langs_xml(self): ''' returns a dictionary which contains all keywords for all defined builtin languages ''' xml_file = os.path.join(self.npp_config_dir, 'langs.xml') xml_doc = et.parse(xml_file) lexer_keywords = dict() for lang in xml_doc.findall('Languages/Language'): lexer_keywords[lang.attrib['name']] = lang.findall('Keywords') return lexer_keywords def paint_it(self, color, start, length): ''' Does the coloring by using an indicator ''' editor.setIndicatorCurrent(INDICATOR_ID) editor.setIndicatorValue(color | SC_INDICVALUEBIT) editor.indicatorFillRange(start, length) def main(self, lexer): ''' Gathers the needed information for the current selected lexer and sets these in the hidden scintilla. Calls hidden scintillas colourise method and retrieves the needed colors and their position. Finally sets it in the active document ''' text = editor.getSelText() text_length = len(text) if not text_length: notepad.messageBox('Nothing selected!', 'Error',0) return if not lexer: notepad.messageBox('lexer expected, received: {}'.format(lexer), 'Error',0) return offset = min(editor.getSelectionStart(), editor.getSelectionEnd()) # unfortunately udls behave different than builtin lexers # there for this hack until the secrets get revealed if lexer.startswith('udf - '): active_buffer = notepad.getCurrentBufferID() notepad.new() editor.setText(text) notepad.runMenuCommand('Language', lexer[6:]) styles = [(pos, editor.styleGetFore(editor.getStyleAt(pos))) for pos in range(text_length)] editor.undo() notepad.close() notepad.activateBufferID(active_buffer) for position, color in styles: self.paint_it(color[0] + (color[1] << 8) + (color[2] << 16), offset+position, 1) return # we are done here # else part - aka builtin lexer self.get_lexer_styles(lexer) keywords = self.lexer_keywords.get(lexer, None) self.hidden_scintilla.styleClearAll() self.hidden_scintilla.setLexerLanguage(lexer) if keywords: # not all lexers do have keywords, e.g. xml lexer for i, _keywords in enumerate(keywords): self.hidden_scintilla.setKeyWords(i, _keywords.text) self.hidden_scintilla.setText(text) self.hidden_scintilla.colourise(0, text_length) styles = [(pos, self.hidden_scintilla.getStyleAt(pos)) for pos in range(text_length)] color = self.styler_dict.get(self.default_id, None) if color is None: return self.paint_it(color, offset, text_length) # TODO: can default color different previous_style = [] sorted_styles = dict() for pos, style in styles: if previous_style: if previous_style[0] == style: previous_style[2] += 1 else: if previous_style[0] != 0: if previous_style[0] in sorted_styles: sorted_styles[previous_style[0]].append((previous_style[1],previous_style[2])) else: sorted_styles[previous_style[0]] = [(previous_style[1],previous_style[2])] previous_style = [style, pos, 1] else: previous_style = [style, pos, 1] for k, v in sorted_styles.items(): color = self.styler_dict.get(k, None) if not color: continue for _v in v: self.paint_it(color, offset+_v[0], _v[1]) def register_document(self): ''' store current buffer id in internal list ''' id = notepad.getCurrentBufferID() if id not in self.list_of_document_ids: self.list_of_document_ids.append(id) TextStyler().register_document() print('done') # -------------------------------------------------------------------------- # TESTDATA TESTDATA = ''' Start with an perl example use strict; # comment use warnings; print "Hello, World!\n"; ------------------------------------------------------------------------------ here we have an cpp example #include <iostream> using namespace std; // line comment int main() { /* multi line comment */ cout << "Hello, World!"; return 0; } ------------------------------------------------------------------------------ followed by an rust example fn main() { // Print text to the console println!("Hello World!"); } ------------------------------------------------------------------------------ an xml example <tags> <tag id="0" value="text" /> </tags> ------------------------------------------------------------------------------ an python example class test(object): def __init__(self): self.greet = 'Hello World!' # comment def do_greet(self): print(self.greet) ------------------------------------------------------------------------------ and finally udl markdown \1-2-3 *multiple italic*, **multi bold** and ***multi bold italic*** I have *a pen **I have an apple** uuh* Apple pen. I have **a pen *I have a pineapple* uuh** Pineapple pen! I have *a pen __I have an apple__ uuh* Apple pen. I have **a pen _I have a pineapple_ uuh** Pineapple pen! \* apple \* pen \* <!-- escape test \* t \* t \* t --> ```js var a = 1 * 1 ``` ****** <!-- hr --> ## Bullet point test - normal text * This should be normal text * mess up *some thing* (\* suppose \* it's \* normal) * This should be normal text ''' # --------------------------------------------------------------------------
  • Most of my plugins stopped loading after latest update

    Locked
    3
    1 Votes
    3 Posts
    630 Views
    dinkumoilD

    @eappell

    Since Notepad++ v7.6 the plugin management system has undergone some changes. In v7.6.3 and above every plugin needs to be moved to a separate folder under <Notepad++-install-dir>\plugins which has to be named like the plugin’s DLL file itself.

    Example: If a plugin’s DLL file name is ABC.dll it has to be moved to <Notepad++-install-dir>\plugins\ABC.

    Please note: If a plugin needs some companion files, mostly they need to be moved to that folder too. If these companion files have been located in e.g. <Notepad++-install-dir>\plugins\doc they have to be moved to <Notepad++-install-dir>\plugins\<Plugin-name>\doc, i.e. the former folder structure has to be kept. Sometimes, depending on the plugin, that even means that the folder <Plugin-name> has to be doubled, i.e. <Notepad++-install-dir>\plugins\<Plugin-name>\<Plugin-name>.

    Some plugins use hard coded access paths to their companion files, thus they will not find them at the new location. In that case the companion files have to stay at their old location (where they have been stored in Notepad++ versions prior to v7.6).

    If you have a lot of plugins you could use a script I wrote to automate the migration process. But be aware of the restrictions mentioned above! They are also applicable when using this script.

    You can download a ZIP file containing the script >>> from here <<<. You can read a description of the script >>> here <<<.

  • Shouldn't paste be made respecting correct space (at least) Preference?

    Locked
    10
    1 Votes
    10 Posts
    2k Views
    EkopalypseE

    @Alan-Kilborn

    Thanks, but most of it is stolen from other codes :-D
    But there are so many functions scintilla provide, I assume there are still some Perls out there which we haven’t figured out yet. :-)

    Name, what do you expect? :-D LOL - it gets converted anyway LOL

  • Using caret (circumflex) key for a shortcut

    Locked
    10
    0 Votes
    10 Posts
    5k Views
    dinkumoilD

    @Egon-Olsen , @Alan-Kilborn , @Ekopalypse

    Yeah, it’s the old new thing about keyboard layouts.

    On all PC keyboards world wide, no matter of which locale, keys have the same scan codes depending on their physical position on the keyboard. The keyboard driver for a certain locale translates them (under Windows) into virtual key codes. That’s what applications see when they read keyboard input. These virtual key codes are translated into the actual glyphs of the characters (at the end of the day a bitmap image) when they are displayed on the screen.

    If the keyboard driver supports so called “dead keys” it waits for a second key press to compose them to a resulting character, e.g. all these â,ê,î,ô,û,… letters used in various european languages. This way there are not so much weird key combos to input these characters.

    Unfortunately, in the shortcut mapper of Notepad++ all this isn’t taken into account. The person who programmed the key selector has used a hard coded table for the mapping of physical keys to their character representation, which is wrong for most locales. I wasn’t able to figure out yet, which keyboard locale this person used as a basis for the mapping.

    This is the mapping table for german keyboards between the key list in Notepad++'s shortcut mapper and the physical keys:

    | Npp shortcut mapper | German Keyboard | | |---------+------------| | | solo | with SHIFT | |---------------------+---------+------------| | ~ | ö | Ö | | - | - | _ | | = | + | * | | [ | ß | ? | | ] | ´ (DK) | ` (DK) | | ; | ü | Ü | | ' | ä | Ä | | \ | ^ (DK) | ° | | , | , | ; | | . | . | : | | / | # | ' | | <> | < | > |

    (DK) marks dead keys.

    I often thought about filing an issue about that but I think it will be nothing more than another forgotten minor bug in the issue tracker…

  • Replace Unicode values with characters (e.g. \u00e9 with é)

    Locked
    2
    0 Votes
    2 Posts
    4k Views
    Meta ChuhM

    welcome to the notepad++ community, @Morney-le-Roux

    you need to install the plugin HTML Tag, by using the built in plugins admin on newer versions of notepad++, or using the old plugin manager, if you are on notepad++ 7.5.9 or below.

    once installed, select your partial or complete text, like “ADAMS, Andr\u00e9as” and go to plugins > html tag > decode js, to get “ADAMS, Andréas”.

    best regards.

  • Can notepad++ work with Windows speech recognition ?

    Locked
    2
    0 Votes
    2 Posts
    3k Views
    Meta ChuhM

    welcome to the notepad++ community, @Angelo-Bancheri

    if you have managed to get windows 10 speech recognition to work for any other language than english, you will be able to start dictating by pressing windows + h.

    windows speech recognition will just simulate a keyboard entry, and type into any active editor or text field, but it is a pain in the a. to get it working at all and you will have to google a lot to get it going.

    once you’ve managed to get it running on windows by using one of the guides around, depending on your language, test it with word or notepad.exe first.

    best regards.

  • "install" disappears from the context menu if INF format is associated

    Locked
    1
    0 Votes
    1 Posts
    350 Views
    No one has replied
  • Control+B does not work correctly. Why?

    Locked
    5
    0 Votes
    5 Posts
    2k Views
    Alan KilbornA

    @Michael-Vincent

    IMO that isn’t a great solution either because, when you repeat the operation, without first moving the caret manually, you should again end up where you start. And in the case of your NppExec script, and the OP’s original text, that doesn’t happen when you start with your insert caret just to the left of ((not.

  • Need text removed after space

    Locked
    3
    0 Votes
    3 Posts
    4k Views
    Yamilet BrownY

    OMG!! it worked… thank you so so much ☻

  • adding values to "references" in properties of m3u file?

    11
    0 Votes
    11 Posts
    2k Views
    rddimR

    @Jonathan-Grant

    I think your problem is with the audio device, not with N++. I found some comments that says it might be a firmware problem but I forgot the forum name. Try to search for the problem.

    This is my last answer for that topic, because this is a Notepad++ Community. I hope you can find a sollution!

  • Skip certain extensions in File Search

    Locked
    3
    0 Votes
    3 Posts
    1k Views
    Alan KilbornA

    @Dandello2000

    So there is one extension you want to skip; but how many different ones are there to include? If a small number, the obvious solution is to exclude the one you don’t want by including all those you do want.

  • Run Open Script

    Locked
    7
    0 Votes
    7 Posts
    1k Views
    Meta ChuhM

    @Alan-Kilborn

    yes.
    as far as i have seen, the numbering was introduced before the search filter was added, to allow supporters to say e.g. “go to line 143”.

    you are correct, the numbering is still generated at the time of displaying, and not taken from a table, created once, when shortcut mapper is initialised.

  • load header file with same name as the current c file

    14
    2 Votes
    14 Posts
    2k Views
    Jim DaileyJ

    @Ion-Marqvardsen
    You might want to install the Solution Tools plug-in. I use it and the <Ctrl>~ hotkey to cycle among files having the same name and various different file extensions.

    See here: http://npp.incrediblejunior.com/

  • Bookmarks are gone after closing the file

    Locked
    9
    0 Votes
    9 Posts
    4k Views
    gstaviG

    The devil is in the details. We, the users, want our bookmarks to be remembered. But what is bookmark?

    Is it line number?
    Is it line text?
    What should happen when file is modified externally?
    If I put a bookmark on line 100 and adds 10 lines at the beginning of file, bookmark will jump to 110. Now, when I close the file without saving it, what should be remembered? There could has been 1000 different edits that added and removed random lines.
    What if the bookmark was placed on a line that was never saved?

    For IDEs that are workspace oriented things are (a bit) easier because bookmarks can be saved as part of the workspace meta files. Notepad++ is not workspace oriented.

    Having bookmarks saved as part of the session is a reasonable compromise. I don’t think that core Notepad++ should go beyond that. Find someone to implement Long-Term-Bbookmark-Storage plugin.

  • Adding multiple lines to the bottom of documents

    Locked
    9
    0 Votes
    9 Posts
    1k Views
    David Smith179D

    Hi Guy,

    I found time to have a go - and totally screwed it up! On a few test files only thank goodness. Second attempt worked perfectly. I have since applied the solution to all my php files and uploaded them and, yers they do work.
    https://www.minibottlelibrary.com/mbl/index.html (straights area)

    Again, MANY THANKS.

    David

  • 0 Votes
    7 Posts
    2k Views
    FDWojoF

    I must admit to being a bit embarrassed. I had been looking thru TextFX for a menu item called “JOIN TEXT” and hadn’t found anything. But in looking, I scanned right over the phrase “UNWRAP TEXT”. <oops!>

    That works perfectly.

    Thanks for helping to correct an ignorant user.

    I gotta say that I had noticed other topics in here and a lot of times there were multiple day delays before the original poster got a response. You guys have been so helpful, and responding in only hours, or sometimes minutes.

    THANK YOU TO BOTH OF YOU!

    Frank

  • Bug in Javascript ES2015

    Locked
    5
    0 Votes
    5 Posts
    719 Views