Community
    • Login
    1. Home
    2. Popular
    Log in to post
    • All Time
    • Day
    • Week
    • Month
    • All Topics
    • New Topics
    • Watched Topics
    • Unreplied Topics

    • All categories
    • S

      Minor bug : The "This file has been modified" causes the "mouse up" event to be missing, sticking the selection drag

      Watching Ignoring Scheduled Pinned Locked Moved General Discussion
      2
      1
      0 Votes
      2 Posts
      159 Views
      Alan KilbornA
      @shodanx2 See HERE.
    • sound-fxS

      Scripts to align text

      Watching Ignoring Scheduled Pinned Locked Moved Notepad++ & Plugin Development
      5
      4 Votes
      5 Posts
      5k Views
      sound-fxS
      I’ve added an option to pad to the right side of the selected character. This preserves the character’s position and instead aligns the non-space text to the right of the character. The default pads to the left side, so the character itself gets aligned. A complementary set of scripts, align_text_right.py and align_text_right_1.py, use this new option. Here’s the complete set of scripts. align_text.py: #------------------------------------------------------------------------ # If the character specified in the current selection is a white space, # then prompt the user to enter the alignment character (or characters), # using this character as the initial default. #------------------------------------------------------------------------ default_align_char = ',' from enum import Enum class PaddingSide(Enum): LEFT = 0 RIGHT = 1 def align_selected_text(max_align_char_count = None, padding_side = PaddingSide.LEFT): """Insert padding into the lines in the selection, as needed, to align up to max_align_char_count instances of a specific character or string of characters The default is to align all instances of the specific character. At present, the alignment character is taken as the character at the top of the current selection. You can uncomment some code below to change this policy to instead take the alignment character from within the selection at whichever end has the cursor. Either way, if that character is white space, the user is prompted to type the character (or characters). If you really wish to align on a white space character, you can just click OK at the prompt. When prompted to type the alignment character, the user may enter a sequence of characters, e.g., "-->", in which case the alignment is on the instances of that entire character sequence. For example, if the user enters "-->" at the prompt, then instances of the "-" character get aligned only if they're followed immediately by the characters "->", while instances of, say, "-1" and "- " remain unaltered. If there is no current selection, then aligns all lines in the editor. If there is a current selection, then aligns only the lines that are at least partially included in the selection, and the selection is changed to the entire block of newly-padded lines. Parameters ---------- max_align_char_count : positive integer, optional The maximum number of instances to align of the specific character. For example, set to 1 to align only the first instance of the character on each line. The default is to align all instances of the specific character. padding_side : instance of PaddingSide, optional Indicates which side of the character gets the padding. The default is PaddingSide.LEFT, so the character itself gets aligned. Set to PaddingSide.RIGHT to preserve the character's position and instead align the non-space text to the right of the character. """ from Npp import editor #---------------------------------------------------------------------------- # For the alignment character, take the character just inside the bounds of # the selection block (at either the start or the end, as determined below). #---------------------------------------------------------------------------- editor.targetFromSelection() selected_text = editor.getTargetText() #---------------------------------------------------------------------------- # Use this code to get the align_char unconditionally from the start # of the selection. If there is no selection, use the character at the # current cursor position; if that is unavailable, fall through to the # prompt below by treating the alignment character as whitespace. #---------------------------------------------------------------------------- if selected_text: align_char = selected_text[0] else: current_pos = editor.getCurrentPos() align_char = editor.getTextRangeFull(current_pos, current_pos + 1) if not align_char: align_char = ' ' #---------------------------------------------------------------------------- # Optionally use this code to get the align_char from within the selection # at whichever end has the cursor. #---------------------------------------------------------------------------- # if selected_text: # (startByte, endByte) = editor.getUserCharSelection() # if startByte == editor.getCurrentPos(): # align_char = selected_text[0] # else: # align_char = selected_text[-1] # else: # current_pos = editor.getCurrentPos() # align_char = editor.getTextRangeFull(current_pos, current_pos + 1) # if not align_char: # align_char = ' ' # If the character from the selection seems implausible as the # align_char, then prompt the user for it. if align_char.isspace(): from Npp import notepad global default_align_char align_char = notepad.prompt('Align character:', 'Enter Alignment Character', default_align_char) if align_char is not None: default_align_char = align_char #---------------------------------------------------------------------------- #%% Get the lines of text within the selected alignment block #---------------------------------------------------------------------------- (startLine, endLine) = editor.getUserLineSelection() startPos = editor.positionFromLine(startLine) endPos = editor.getLineEndPosition(endLine) text_lines = editor.getTextRangeFull(startPos, endPos).splitlines(True) #---------------------------------------------------------------------------- # Remember whether there is a user-selected block, so we can restore a # corresponding selection after aligning the text. #---------------------------------------------------------------------------- restore_selection = editor.getSelectionStart() != editor.getSelectionEnd() #---------------------------------------------------------------------------- # Align all instances of align_char within the lines of text #---------------------------------------------------------------------------- if align_char is not None: # Enable the following to save the align_char, however it was determined, # to be the default_align_char when prompting for it next time. # default_align_char = align_char if max_align_char_count is None: align_char_count = max(line.count(align_char) for line in text_lines) else: align_char_count = max_align_char_count start = 0 for instance in range(align_char_count): # Set the target column using the index of the align_char, ignoring # immediately preceding space, or the length of the line align_char_cols = [line.find(align_char, start) for line in text_lines] # Only lines that contain this instance participate in this pass. # A failed find() returns -1, and using that as a slice index would # make lines without this instance incorrectly affect the target. lines_with_instance = [(line, col) for (line, col) in zip(text_lines, align_char_cols) if col >= 0] if not lines_with_instance: break if padding_side == PaddingSide.LEFT: # Align the alignment character itself, removing any spaces # immediately to its left before inserting the required padding. target_col = max(len(line[:col].rstrip()) for (line, col) in lines_with_instance) for (idx, line) in enumerate(text_lines): align_char_col = align_char_cols[idx] if align_char_col >= 0: text_lines[idx] = line[:align_char_col].rstrip().ljust(target_col) \ + line[align_char_col:] start = target_col + len(align_char) elif padding_side == PaddingSide.RIGHT: # Align the non-space text after the alignment character. # Preserve the alignment character itself, but # replace any existing spaces after it with the required # padding. suffix_starts = [] for (line, col) in lines_with_instance: suffix_start = col + len(align_char) while suffix_start < len(line) and line[suffix_start] == ' ': suffix_start += 1 suffix_starts.append(suffix_start) target_col = max(suffix_starts) for (idx, line) in enumerate(text_lines): align_char_col = align_char_cols[idx] if align_char_col >= 0: suffix_start = align_char_col + len(align_char) while suffix_start < len(line) and line[suffix_start] == ' ': suffix_start += 1 text_lines[idx] = line[:align_char_col + len(align_char)].ljust(target_col) \ + line[suffix_start:] start = target_col else: raise ValueError('Unsupported padding_side: {}'.format(padding_side)) editor.setTarget(startPos, endPos) editor.replaceTarget(''.join(text_lines)) if restore_selection: startPos = editor.positionFromLine(startLine) endPos = editor.getLineEndPosition(endLine) editor.setSelectionStart(startPos) editor.setSelectionEnd(endPos) if __name__ == '__main__': align_selected_text() align_text_1.py: from align_text import align_selected_text align_selected_text(max_align_char_count = 1) align_text_right.py: from align_text import align_selected_text, PaddingSide align_selected_text(padding_side = PaddingSide.RIGHT) align_text_right_1.py: from align_text import align_selected_text, PaddingSide align_selected_text(max_align_char_count = 1, padding_side = PaddingSide.RIGHT)
    • guy038G

      New displaying of the "Search Results" panel

      Watching Ignoring Scheduled Pinned Locked Moved General Discussion
      1
      1
      0 Votes
      1 Posts
      60 Views
      No one has replied
    • donhoD

      v8.9.6 RC will be available in about 3 days

      Watching Ignoring Scheduled Pinned Locked Moved Announcements
      1
      2 Votes
      1 Posts
      75 Views
      No one has replied
    • JWJ

      AI Plugin

      Watching Ignoring Scheduled Pinned Locked Moved Notepad++ & Plugin Development
      3
      1 Votes
      3 Posts
      705 Views
      BlueSea KuoB
      @jw I suggest adding an option to select the AI module.
    • donhoD

      Notepad++ v8.9.5 Release Candidate will be available in 1-2 days

      Watching Ignoring Scheduled Pinned Locked Moved Announcements
      1
      3 Votes
      1 Posts
      247 Views
      No one has replied
    • dz15mlruD

      BUG: N++ does not keep in UTF8 unsaved open files

      Watching Ignoring Scheduled Pinned Locked Moved General Discussion bug cyrillic utf8 encoding
      9
      0 Votes
      9 Posts
      838 Views
      AZJIO AZJIOA
      @dz15mlru Disable automatic encoding recognition. For Windows-1251 encoded Russian, auto-recognition will always open as Macintosh. If you start editing files, you will have two encodings, or rather garbage from two encodings, which will be difficult to fix manually, since you will have to re-read all the texts (this is a module for spoiling files). When you disable automatic encoding assignment, you will only have ANSI, UTF-8, UTF-16. WindowsXP-7-8-10-11 it will always open the ANSI file correctly, in 1251 encoding, as this is the default encoding. The remaining UTF-8 and others will also open automatically correctly. You will get rid of the problem forever. The automatic text encoding recognition module is needed if you open files in Arabic in ANSI, but in reality you will never do this, since a Russian-speaking person has only Russian-language files on their computer. People who want to make the file available to all people on earth save the file in UTF-8 encoding and it will always open correctly for you. You don’t need automatic file recognition, as it’s only for local files that you’ll never get from someone else’s computer abroad. Отключи автоматической распознавание кодировки. Для русского языка в кодировке Windows-1251 автораспознавание всегда будет открываться как Macintosh. Если начать редактировать файлы, то у вас будет две кодировки, точнее мусор из двух кодировок, который будет трудно исправить вручную, так как вам придётся перечитать все тексты (это модуль для порчи файлов). Когда вы отключите автораспозначание кодировки, то у вас будет только ANSI, UTF-8, UTF-16. WindowsXP-7-8-10-11 всегда откроет файл ANSI правильно, в кодировке 1251, так как это кодировка по умолчанию. Остальные UTF-8 и прочие откроются также автоматически правильно. Вы навсегда избавитесь от проблемы. Модуль автоматического распознавания кодировки текста нужен если вы открываете файлы на арабском языке в ANSI, но в реальности вы никогда этого не сделаете, так как у русскоязычного человека на компьютере есть только русскоязычные файлы. Люди, которые хотят сделать файл доступным для всех людей на земле сохраняют файл в кодировке UTF-8 и он всегда откроется правильно у вас. Вам не нужно автоматическое распознавание файлов, так как оно только для локальных файлов, которые у вас никогда не появятся с чужого заграничного компьютера.
    • Jeff EspositoJ

      Notepad++ VERY slow to open

      Watching Ignoring Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
      22
      0 Votes
      22 Posts
      15k Views
      Boku YamiB
      @Jeff-Esposito said in Notepad++ VERY slow to open: e gotten my new computer Notepad++ takes 40-50 seconds to launch. I have removed all plugins and don’t check recent file history at launch is checked. There are no open unsaved tabs, even though that is how I want to use it and use it on my old pc and my work laptop. the install It becomes slow when using “Show Folder As Workspace” (which displays the workspace folder on the left side). It starts quickly when this option is turned off.
    • glossarG

      Invisible spaces

      Watching Ignoring Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
      11
      0 Votes
      11 Posts
      10k Views
      Lucas BrunoL
      Yeah, this usually happens with non-breaking spaces (U+00A0) or other Unicode space characters that look invisible but behave differently from normal spaces. Using \xA0 in regex was the right fix 👍 If you face this again, you can: Use \x{00A0} or \s to detect space variants Check in hex editor to identify exact character Then replace all in one go Also, if you’re unsure which invisible character it is, you can test different ones using tools like espaço invisível before applying them in your editor.
    • xmaticX

      changing the font

      Watching Ignoring Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
      5
      1
      0 Votes
      5 Posts
      2k Views
      H
      Honestly, this cleared up a big confusion for me. I used to think fonts were saved with the file itself, but it makes sense now that it’s just the editor displaying it differently. Also didn’t realize enabling global font overrides can mess with syntax highlighting—good catch. I’ve been tweaking text styles a lot lately while testing name formats on font generator, so this helps keep things consistent
    • guy038G

      Surprising regular expression !

      Watching Ignoring Scheduled Pinned Locked Moved Blogs
      1
      1 Votes
      1 Posts
      377 Views
      No one has replied
    • donhoD

      All the off-topic go here

      Watching Ignoring Scheduled Pinned Locked Moved Boycott Notepad++
      9
      3 Votes
      9 Posts
      7k Views
      guy038G
      Hello, @peterjones and All, Peter, in one of your posts, that I cannot seem to find, you mentioned a new feature in Windows 11 Notepad that, by default, allows you to close the application, even if there are unsaved files, similar to Notepad++ Just in case you have not figured out, on your own, how to change this default behavior ( witch would really surprise me ! ), here is the method : Open Microsoft Notepad Click on the gear icon, on far right of the Menu bar Look for the line When Notepad starts Click on the arrow on the far right of this option Select the Start new session and discard unsaved changes option Close and re-start Notepad => The old Notepad behavior should be back with just an untitled tab when starting Microsoft Notepad ! Best Regards, guy038