mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Delete whole word with Shift+Del
Here should be Control+Backspace but https://github.com/prompt-toolkit/python-prompt-toolkit/issues/257#issuecomment-190328366
This commit is contained in:
parent
b29a467076
commit
7f15ff0a64
1 changed files with 12 additions and 0 deletions
|
@ -28,3 +28,15 @@ def custom_keybindings(bindings, **kw):
|
|||
pos = buff.document.find_next_word_ending(count=event.arg, WORD=True)
|
||||
if pos:
|
||||
buff.cursor_position += pos
|
||||
|
||||
@bindings.add(Keys.ShiftDelete)
|
||||
def shift_delete(event):
|
||||
buff = event.current_buffer
|
||||
startpos, endpos = buff.document.find_boundaries_of_current_word(WORD=True)
|
||||
startpos = buff.cursor_position + startpos - 1
|
||||
startpos = 0 if startpos < 0 else startpos
|
||||
endpos = buff.cursor_position + endpos
|
||||
endpos = endpos + 1 if startpos == 0 else endpos
|
||||
buff.text = buff.text[:startpos] + buff.text[endpos:]
|
||||
buff.cursor_position = startpos
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue