Answers:
我在Notepad ++社区页面上找到了该线程:
https://notepad-plus-plus.org/community/topic/11360/multi-selection-and-multi-edit
他们正在使用python脚本插件通过以下脚本创建此功能:
# 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()
是的,Notepad ++中具有“选择并查找下一个”功能。
组合键是。
Ctrl + F3
并选择以前的出现。
Ctrl+ Shift+F3
您可以在“ 搜索”菜单下签出。
float
,您按了组合键,现在第二次出现的float
已添加到多重选择中。然后,您可以键入double
替换两个occurances(并保持文件的其余部分不变)