Encontré este hilo en la página de la comunidad Notepad ++:
https://notepad-plus-plus.org/community/topic/11360/multi-selection-and-multi-edit
Están utilizando el complemento de secuencia de comandos de Python para crear esta funcionalidad con la siguiente secuencia de comandos:
# this script implements the enhanced multi cursor edit functionality
def default_positions():
return 0, editor.getLength()
def get_pos_of_bookmarks():
npp_bookmark_marker_id_number = 24
npp_bookmark_marker_mask = 1 << npp_bookmark_marker_id_number
_start_position, _end_position = default_positions()
line_nbr = editor.markerNext(_start_position, npp_bookmark_marker_mask)
if line_nbr != -1:
_start_position = editor.positionFromLine(line_nbr)
line_nbr = editor.markerNext(line_nbr + 1, npp_bookmark_marker_mask)
if line_nbr != -1:
_end_position = editor.getLineEndPosition(line_nbr)
return _start_position, _end_position
def get_pos_of_visible_lines():
first_visible_line = editor.getFirstVisibleLine()
_start_position = editor.positionFromLine(first_visible_line)
lines_visible = editor.linesOnScreen()
last_visible_line = editor.docLineFromVisible(first_visible_line+lines_visible)
_end_position = editor.getLineEndPosition(last_visible_line)
return _start_position, _end_position
def get_pos_of_selections():
_start_position, _end_position = default_positions()
if editor.getSelections() == 2:
_start_position = editor.getSelectionNStart(0)
_end_position = editor.getSelectionNEnd(1)
return _start_position, _end_position
area_dict = {'a':default_positions,
'b':get_pos_of_bookmarks,
's':get_pos_of_selections,
'v':get_pos_of_visible_lines}
editor.beginUndoAction()
def Main():
_text = editor.getTextRange(editor.getSelectionNStart(0), editor.getSelectionNEnd(0))
if len(_text) != 0:
_current_position = editor.getCurrentPos()
_current_line = editor.lineFromPosition(_current_position)
_current_word_start_pos = editor.getLineSelStartPosition(_current_line)
_current_word_end_pos = editor.getLineSelEndPosition(_current_line)
find_flag = 2 # 0=DEFAULT, 2=WHOLEWORD 4=MATCHCASE 6=WHOLEWORD | MATCHCASE
mode_options = ' 0=replace, 1=before, 2=afterwards\n'
area_options = ' a=all, b=bookmarks, s=selected, v=visible'
expected_results = [x+y for x in ['0','1','2'] for y in ['a','b','s','v']]
result = notepad.prompt(mode_options + area_options, 'Choose the desired option', '0a')
while result not in expected_results:
if result is None:
return
result = notepad.prompt(mode_options + area_options, 'Choose the desired option', '0a')
chosen_mode, chosen_area = result
area_start_position, area_end_position = area_dict[chosen_area]()
if chosen_mode == '0': # replace whole string version
editor.setEmptySelection(_current_position)
position_tuple = editor.findText(find_flag, area_start_position, area_end_position, _text)
while position_tuple is not None:
if _current_position not in position_tuple:
editor.addSelection(*position_tuple)
position_tuple = editor.findText(find_flag, position_tuple[1], area_end_position, _text)
elif chosen_mode == '1': # insert before selected string version
editor.setEmptySelection(_current_word_start_pos)
position_tuple = editor.findText(find_flag, area_start_position, area_end_position, _text)
while position_tuple is not None:
startpos, endpos = position_tuple
if startpos != _current_position and endpos != _current_position:
editor.addSelection(startpos, startpos)
else:
_current_word_start_pos, _current_word_end_pos = startpos, startpos
position_tuple = editor.findText(find_flag, endpos, area_end_position, _text)
elif chosen_mode == '2': # insert after selected string version
editor.setEmptySelection(_current_word_end_pos)
position_tuple = editor.findText(find_flag, area_start_position, area_end_position, _text)
while position_tuple is not None:
startpos, endpos = position_tuple
if startpos != _current_position and endpos != _current_position:
editor.addSelection(endpos, endpos)
else:
_current_word_start_pos, _current_word_end_pos = endpos, endpos
position_tuple = editor.findText(find_flag, endpos, area_end_position, _text)
# now add the current selection
editor.addSelection(_current_word_start_pos, _current_word_end_pos)
Main()
editor.endUndoAction()
Puede presionar F3para continuar buscando.
fuente
Sí, la función "Seleccionar y buscar siguiente" está en Notepad ++.
La combinación de teclas para esto es.
Ctrl + F3
Y para seleccionar la ocurrencia anterior es.
Ctrl+ Shift+F3
Puede consultarlo en el menú Buscar .
fuente
float
, presiona la combinación de teclas ahorafloat
se agrega la segunda aparición de la selección múltiple. Luego puede escribirdouble
para reemplazar las dos ocurrencias (y mantener el resto del archivo sin cambios)