sublimeless_zk
sublimeless_zk copied to clipboard
Ctrl + Backspace deletes entire sentence instead of a single word
Hi!
Ctrl + Del
deletes whole words to the right of the cursor just fine.
However, Ctrl + Backspace
deletes the whole sentence to the left of the cursor, instead of just a single word.
Is there perhaps a workaround or fix for this? I'm new to the software, so I might have missed something obvious. This issue is experienced in Windows 10.
Rene is a mac user, and that's the default behavior on macOS: cmd+backspace
deletes the entire line. He must not have changed the shortcut for Windows. He's disappeared for the past year or so, so you'd have to edit it in yourself. Just search for the scintilla class and you'll find the right line to revise.
Thanks a lot @drinkitup777, that was indeed the issue.
So for the PC users - without a manual fix, the command for deleting a word will be left Alt key + Backspace
.
Hi again @drinkitup777, I would be very happy if you could help me out with one more detail: How can i access the shortcut data in the Zettelkasten source code?
I know some basic programming, but I'm not a programmer. Also never used Python. I'm not sure what a scintilla class is, which is why I couldn't use your last comment to find the correct line to revise. I get the impression that Scintilla is a kind of framework for manipulating source code, but it's a bit beyond me.
There's numerous shortkey's I would like to change (I.e. the Show referencing notes uses Alt+Return key, and Windows don't have a Return key other than the Enter key, which doesn't work), so a pointer in the direction of the file containing shortkeys (if they are in one file) would be a huge help.
No worries, in that case I'll just give you my personal keybinds with Windows keybinds included.
Go into src/sublimeless_zk.py
and find the method def init_editor_text_shortcuts(self, editor)
. Replace the entire method with mine:
def init_editor_text_shortcuts(self, editor):
import platform
# Scintilla has some funky default keybinds. Rebind them to something sensible.
commandSet = editor.standardCommands()
commandSet.clearKeys()
commandSet.clearAlternateKeys()
if platform.system() == 'Darwin':
# HACK Unlike wxWidgets, Qt automatically swaps the actual Ctrl and Meta values rather than providing CtrlOrMeta. Thus some fiddling with ctrl and meta is necessary to get the actual ctrl and meta keys
ACTUAL_CTRL_MODIFIER = Qt.ControlModifier
ACTUAL_META_MODIFIER = Qt.MetaModifier
if not PyQt5.QtWidgets.QApplication.testAttribute(Qt.AA_MacDontSwapCtrlAndMeta):
ACTUAL_META_MODIFIER = Qt.ControlModifier
ACTUAL_CTRL_MODIFIER = Qt.MetaModifier
# macOS keybinds
commandSet.find(QsciCommand.LineDown).setKey(Qt.Key_Down)
commandSet.find(QsciCommand.LineDownExtend).setKey(Qt.ShiftModifier | Qt.Key_Down)
# QsciCommand.LineDownRectExtend
# QsciCommand.LineScrollDown
commandSet.find(QsciCommand.LineUp).setKey(Qt.Key_Up)
commandSet.find(QsciCommand.LineUpExtend).setKey(Qt.ShiftModifier | Qt.Key_Up)
# QsciCommand.LineUpRectExtend
# QsciCommand.LineScrollUp
# QsciCommand.ScrollToStart
# QsciCommand.ScrollToEnd
# QsciCommand.VerticalCentreCaret
commandSet.find(QsciCommand.ParaDown).setKey(Qt.AltModifier | Qt.Key_Down)
commandSet.find(QsciCommand.ParaDownExtend).setKey(Qt.AltModifier | Qt.ShiftModifier | Qt.Key_Down)
commandSet.find(QsciCommand.ParaUp).setKey(Qt.AltModifier | Qt.Key_Up)
commandSet.find(QsciCommand.ParaUpExtend).setKey(Qt.AltModifier | Qt.ShiftModifier | Qt.Key_Up)
commandSet.find(QsciCommand.CharLeft).setKey(Qt.Key_Left)
commandSet.find(QsciCommand.CharLeftExtend).setKey(Qt.ShiftModifier | Qt.Key_Left)
# QsciCommand.CharLeftRectExtend
commandSet.find(QsciCommand.CharRight).setKey(Qt.Key_Right)
commandSet.find(QsciCommand.CharRightExtend).setKey(Qt.ShiftModifier | Qt.Key_Right)
# QsciCommand.CharRightRectExtend
commandSet.find(QsciCommand.WordLeft).setKey(Qt.AltModifier | Qt.Key_Left)
commandSet.find(QsciCommand.WordLeftExtend).setKey(Qt.ShiftModifier | Qt.AltModifier | Qt.Key_Left)
# QsciCommand.WordRight
# QsciCommand.WordRightExtend
# QsciCommand.WordLeftEnd
# QsciCommand.WordLeftEndExtend
commandSet.find(QsciCommand.WordRightEnd).setKey(Qt.AltModifier | Qt.Key_Right)
commandSet.find(QsciCommand.WordRightEndExtend).setAlternateKey(Qt.ShiftModifier | Qt.AltModifier | Qt.Key_Right)
# QsciCommand.WordPartLeft
# QsciCommand.WordPartLeftExtend
# QsciCommand.WordPartRight
# QsciCommand.WordPartRightExtend
# QsciCommand.Home
# QsciCommand.HomeExtend
# QsciCommand.HomeRectExtend
# QsciCommand.HomeDisplay
# QsciCommand.HomeDisplayExtend
# QsciCommand.HomeWrap
# QsciCommand.HomeWrapExtend
# QsciCommand.VCHome
# QsciCommand.VCHomeExtend
# QsciCommand.VCHomeRectExtend
commandSet.find(QsciCommand.VCHomeWrap).setKey(Qt.Key_Home)
commandSet.find(QsciCommand.VCHomeWrap).setAlternateKey(ACTUAL_META_MODIFIER | Qt.Key_Left)
commandSet.find(QsciCommand.VCHomeWrapExtend).setKey(Qt.ShiftModifier | Qt.Key_Home)
commandSet.find(QsciCommand.VCHomeWrapExtend).setAlternateKey(Qt.ShiftModifier | ACTUAL_META_MODIFIER | Qt.Key_Left)
# QsciCommand.LineEnd
# QsciCommand.LineEndExtend
# QsciCommand.LineEndRectExtend
# QsciCommand.LineEndDisplay
# QsciCommand.LineEndDisplayExtend
commandSet.find(QsciCommand.LineEndWrap).setKey(Qt.Key_End)
commandSet.find(QsciCommand.LineEndWrap).setAlternateKey(ACTUAL_META_MODIFIER | Qt.Key_Right)
commandSet.find(QsciCommand.LineEndWrapExtend).setKey(Qt.ShiftModifier | Qt.Key_End)
commandSet.find(QsciCommand.LineEndWrapExtend).setAlternateKey(Qt.ShiftModifier | ACTUAL_META_MODIFIER | Qt.Key_Right)
commandSet.find(QsciCommand.DocumentStart).setKey(ACTUAL_META_MODIFIER | Qt.Key_Home)
commandSet.find(QsciCommand.DocumentStart).setAlternateKey(ACTUAL_META_MODIFIER | Qt.Key_Up)
commandSet.find(QsciCommand.DocumentStartExtend).setKey(ACTUAL_META_MODIFIER | Qt.ShiftModifier | Qt.Key_Home)
commandSet.find(QsciCommand.DocumentStartExtend).setAlternateKey(ACTUAL_META_MODIFIER | Qt.ShiftModifier | Qt.Key_Up)
commandSet.find(QsciCommand.DocumentEnd).setKey(ACTUAL_META_MODIFIER | Qt.Key_End)
commandSet.find(QsciCommand.DocumentEnd).setAlternateKey(ACTUAL_META_MODIFIER | Qt.Key_Down)
commandSet.find(QsciCommand.DocumentEndExtend).setKey(ACTUAL_META_MODIFIER | Qt.ShiftModifier | Qt.Key_End)
commandSet.find(QsciCommand.DocumentEndExtend).setAlternateKey(ACTUAL_META_MODIFIER | Qt.ShiftModifier | Qt.Key_Down)
commandSet.find(QsciCommand.PageUp).setKey(Qt.Key_PageUp)
commandSet.find(QsciCommand.PageUpExtend).setKey(Qt.ShiftModifier | Qt.Key_PageUp)
# QsciCommand.PageUpRectExtend
commandSet.find(QsciCommand.PageDown).setKey(Qt.Key_PageDown)
commandSet.find(QsciCommand.PageDownExtend).setKey(Qt.ShiftModifier | Qt.Key_PageDown)
# QsciCommand.PageDownRectExtend
# QsciCommand.StutteredPageUp
# QsciCommand.StutteredPageUpExtend
# QsciCommand.StutteredPageDown
# QsciCommand.StutteredPageDownExtend
commandSet.find(QsciCommand.Delete).setKey(Qt.Key_Delete)
commandSet.find(QsciCommand.DeleteBack).setKey(Qt.Key_Backspace)
# QsciCommand.DeleteBackNotLine
commandSet.find(QsciCommand.DeleteWordLeft).setKey(Qt.AltModifier | Qt.Key_Backspace)
# QsciCommand.DeleteWordRight
# TODO DeleteWordRight and DeleteWordRightEnd seem to behave identically. Find out if there are actually any differences between the two
commandSet.find(QsciCommand.DeleteWordRightEnd).setKey(Qt.AltModifier | Qt.Key_Delete)
commandSet.find(QsciCommand.DeleteLineLeft).setKey(ACTUAL_META_MODIFIER | Qt.Key_Backspace)
commandSet.find(QsciCommand.DeleteLineRight).setKey(ACTUAL_META_MODIFIER | Qt.Key_Delete)
# QsciCommand.LineDelete
# QsciCommand.LineCut
# QsciCommand.LineCopy
# QsciCommand.LineTranspose
# SelectionDuplicate will duplicate the current line if nothing is selected (and is thus superior to LineDuplicate)
# QsciCommand.LineDuplicate
commandSet.find(QsciCommand.SelectAll).setKey(ACTUAL_META_MODIFIER | Qt.Key_A)
commandSet.find(QsciCommand.MoveSelectedLinesUp).setKey(ACTUAL_META_MODIFIER | ACTUAL_CTRL_MODIFIER | Qt.Key_Up)
commandSet.find(QsciCommand.MoveSelectedLinesDown).setKey(ACTUAL_META_MODIFIER | ACTUAL_CTRL_MODIFIER | Qt.Key_Down)
# If nothing is selected, this will duplicate the line the cursor is currently on.
commandSet.find(QsciCommand.SelectionDuplicate).setKey(ACTUAL_META_MODIFIER | Qt.ShiftModifier | Qt.Key_D)
commandSet.find(QsciCommand.SelectionLowerCase).setKey(ACTUAL_META_MODIFIER | Qt.ShiftModifier | Qt.Key_L)
commandSet.find(QsciCommand.SelectionUpperCase).setKey(ACTUAL_META_MODIFIER | Qt.ShiftModifier | Qt.Key_U)
commandSet.find(QsciCommand.SelectionCut).setKey(ACTUAL_META_MODIFIER | Qt.Key_X)
commandSet.find(QsciCommand.SelectionCut).setAlternateKey(Qt.ShiftModifier | Qt.Key_Delete)
commandSet.find(QsciCommand.SelectionCopy).setKey(ACTUAL_META_MODIFIER | Qt.Key_C)
commandSet.find(QsciCommand.SelectionCopy).setAlternateKey(ACTUAL_META_MODIFIER | Qt.Key_Insert) # FIXME Ctrl+Ins does not respond (on macOS at least)
commandSet.find(QsciCommand.Paste).setKey(ACTUAL_META_MODIFIER | Qt.Key_V)
commandSet.find(QsciCommand.Paste).setAlternateKey(Qt.ShiftModifier | Qt.Key_Insert) # FIXME Shift+Ins does not respond (on macOS at least)
commandSet.find(QsciCommand.EditToggleOvertype).setKey(Qt.Key_Insert) # FIXME The Ins key does not respond (on macOS at least)
commandSet.find(QsciCommand.Newline).setKey(Qt.Key_Return)
# QsciCommand.Formfeed
commandSet.find(QsciCommand.Tab).setKey(Qt.Key_Tab)
commandSet.find(QsciCommand.Backtab).setKey(Qt.ShiftModifier | Qt.Key_Tab)
commandSet.find(QsciCommand.Cancel).setKey(Qt.Key_Escape)
commandSet.find(QsciCommand.Undo).setKey(ACTUAL_META_MODIFIER | Qt.Key_Z)
commandSet.find(QsciCommand.Redo).setKey(ACTUAL_META_MODIFIER | Qt.Key_Y)
commandSet.find(QsciCommand.Redo).setAlternateKey(Qt.ShiftModifier | ACTUAL_META_MODIFIER | Qt.Key_Z)
# QsciCommand.ZoomIn
# QsciCommand.ZoomOut
# # QsciCommand.ReverseLines
else:
# Windows and Linux keybinds
# AFAIK Linux keybinds are identical to Windows' and so should be interchangeable
commandSet.find(QsciCommand.LineDown).setKey(Qt.Key_Down)
commandSet.find(QsciCommand.LineDownExtend).setKey(Qt.ShiftModifier | Qt.Key_Down)
# QsciCommand.LineDownRectExtend
# QsciCommand.LineScrollDown
commandSet.find(QsciCommand.LineUp).setKey(Qt.Key_Up)
commandSet.find(QsciCommand.LineUpExtend).setKey(Qt.ShiftModifier | Qt.Key_Up)
# QsciCommand.LineUpRectExtend
# QsciCommand.LineScrollUp
# QsciCommand.ScrollToStart
# QsciCommand.ScrollToEnd
# QsciCommand.VerticalCentreCaret
commandSet.find(QsciCommand.ParaDown).setKey(Qt.ControlModifier | Qt.Key_Down)
commandSet.find(QsciCommand.ParaDownExtend).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_Down)
commandSet.find(QsciCommand.ParaUp).setKey(Qt.ControlModifier | Qt.Key_Up)
commandSet.find(QsciCommand.ParaUpExtend).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_Up)
commandSet.find(QsciCommand.CharLeft).setKey(Qt.Key_Left)
commandSet.find(QsciCommand.CharLeftExtend).setKey(Qt.ShiftModifier | Qt.Key_Left)
# QsciCommand.CharLeftRectExtend
commandSet.find(QsciCommand.CharRight).setKey(Qt.Key_Right)
commandSet.find(QsciCommand.CharRightExtend).setKey(Qt.ShiftModifier | Qt.Key_Right)
# QsciCommand.CharRightRectExtend
commandSet.find(QsciCommand.WordLeft).setKey(Qt.ControlModifier | Qt.Key_Left)
commandSet.find(QsciCommand.WordLeftExtend).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_Left)
# QsciCommand.WordRight
# QsciCommand.WordRightExtend
# QsciCommand.WordLeftEnd
# QsciCommand.WordLeftEndExtend
commandSet.find(QsciCommand.WordRightEnd).setKey(Qt.ControlModifier | Qt.Key_Right)
commandSet.find(QsciCommand.WordRightEndExtend).setAlternateKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_Right)
# QsciCommand.WordPartLeft
# QsciCommand.WordPartLeftExtend
# QsciCommand.WordPartRight
# QsciCommand.WordPartRightExtend
# QsciCommand.Home
# QsciCommand.HomeExtend
# QsciCommand.HomeRectExtend
# QsciCommand.HomeDisplay
# QsciCommand.HomeDisplayExtend
# QsciCommand.HomeWrap
# QsciCommand.HomeWrapExtend
# QsciCommand.VCHome
# QsciCommand.VCHomeExtend
# QsciCommand.VCHomeRectExtend
commandSet.find(QsciCommand.VCHomeWrap).setKey(Qt.Key_Home)
commandSet.find(QsciCommand.VCHomeWrap).setAlternateKey(Qt.AltModifier | Qt.Key_Left)
commandSet.find(QsciCommand.VCHomeWrapExtend).setKey(Qt.ShiftModifier | Qt.Key_Home)
commandSet.find(QsciCommand.VCHomeWrapExtend).setAlternateKey(Qt.ShiftModifier | Qt.AltModifier | Qt.Key_Left)
# QsciCommand.LineEnd
# QsciCommand.LineEndExtend
# QsciCommand.LineEndRectExtend
# QsciCommand.LineEndDisplay
# QsciCommand.LineEndDisplayExtend
commandSet.find(QsciCommand.LineEndWrap).setKey(Qt.Key_End)
commandSet.find(QsciCommand.LineEndWrap).setAlternateKey(Qt.AltModifier | Qt.Key_Right)
commandSet.find(QsciCommand.LineEndWrapExtend).setKey(Qt.ShiftModifier | Qt.Key_End)
commandSet.find(QsciCommand.LineEndWrapExtend).setAlternateKey(Qt.ShiftModifier | Qt.AltModifier | Qt.Key_Right)
commandSet.find(QsciCommand.DocumentStart).setKey(Qt.ControlModifier | Qt.Key_Home)
commandSet.find(QsciCommand.DocumentStartExtend).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_Home)
commandSet.find(QsciCommand.DocumentEnd).setKey(Qt.ControlModifier | Qt.Key_End)
commandSet.find(QsciCommand.DocumentEndExtend).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_End)
commandSet.find(QsciCommand.PageUp).setKey(Qt.Key_PageUp)
commandSet.find(QsciCommand.PageUpExtend).setKey(Qt.ShiftModifier | Qt.Key_PageUp)
# QsciCommand.PageUpRectExtend
commandSet.find(QsciCommand.PageDown).setKey(Qt.Key_PageDown)
commandSet.find(QsciCommand.PageDownExtend).setKey(Qt.ShiftModifier | Qt.Key_PageDown)
# QsciCommand.PageDownRectExtend
# QsciCommand.StutteredPageUp
# QsciCommand.StutteredPageUpExtend
# QsciCommand.StutteredPageDown
# QsciCommand.StutteredPageDownExtend
commandSet.find(QsciCommand.Delete).setKey(Qt.Key_Delete)
commandSet.find(QsciCommand.DeleteBack).setKey(Qt.Key_Backspace)
# QsciCommand.DeleteBackNotLine
commandSet.find(QsciCommand.DeleteWordLeft).setKey(Qt.ControlModifier | Qt.Key_Backspace)
# QsciCommand.DeleteWordRight
# TODO DeleteWordRight and DeleteWordRightEnd seem to behave identically. Find out if there are actually any differences between the two
commandSet.find(QsciCommand.DeleteWordRightEnd).setKey(Qt.ControlModifier | Qt.Key_Delete)
# DeleteLineLeft and DeleteLineRight are not standard Windows keybinds, but they are useful enough to warrant deviating from convention
commandSet.find(QsciCommand.DeleteLineLeft).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_Backspace)
commandSet.find(QsciCommand.DeleteLineRight).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_Delete)
# QsciCommand.LineDelete
# QsciCommand.LineCut
# QsciCommand.LineCopy
# QsciCommand.LineTranspose
# SelectionDuplicate will duplicate the current line if nothing is selected (and is thus superior to LineDuplicate)
# QsciCommand.LineDuplicate
commandSet.find(QsciCommand.SelectAll).setKey(Qt.ControlModifier | Qt.Key_A)
commandSet.find(QsciCommand.MoveSelectedLinesUp).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_Up)
commandSet.find(QsciCommand.MoveSelectedLinesDown).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_Down)
# If nothing is selected, this will duplicate the line the cursor is currently on.
commandSet.find(QsciCommand.SelectionDuplicate).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_D)
commandSet.find(QsciCommand.SelectionLowerCase).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_L)
commandSet.find(QsciCommand.SelectionUpperCase).setKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_U)
commandSet.find(QsciCommand.SelectionCut).setKey(Qt.ControlModifier | Qt.Key_X)
commandSet.find(QsciCommand.SelectionCut).setAlternateKey(Qt.ShiftModifier | Qt.Key_Delete)
commandSet.find(QsciCommand.SelectionCopy).setKey(Qt.ControlModifier | Qt.Key_C)
commandSet.find(QsciCommand.SelectionCopy).setAlternateKey(Qt.ControlModifier | Qt.Key_Insert)
commandSet.find(QsciCommand.Paste).setKey(Qt.ControlModifier | Qt.Key_V)
commandSet.find(QsciCommand.Paste).setAlternateKey(Qt.ShiftModifier | Qt.Key_Insert)
commandSet.find(QsciCommand.EditToggleOvertype).setKey(Qt.Key_Insert)
commandSet.find(QsciCommand.Newline).setKey(Qt.Key_Return)
# QsciCommand.Formfeed
commandSet.find(QsciCommand.Tab).setKey(Qt.Key_Tab)
commandSet.find(QsciCommand.Backtab).setKey(Qt.ShiftModifier | Qt.Key_Tab)
commandSet.find(QsciCommand.Cancel).setKey(Qt.Key_Escape)
commandSet.find(QsciCommand.Undo).setKey(Qt.ControlModifier | Qt.Key_Z)
commandSet.find(QsciCommand.Redo).setKey(Qt.ControlModifier | Qt.Key_Y)
commandSet.find(QsciCommand.Redo).setAlternateKey(Qt.ControlModifier | Qt.ShiftModifier | Qt.Key_Z)
# QsciCommand.ZoomIn
# QsciCommand.ZoomOut
# QsciCommand.ReverseLines
You'll need Python now. Install Python 3 from their website at python.org, making sure you enable add python to PATH
in the installer. Then the command line and run pip3 install pyqt5 qscintilla jstyleson bibtexparser fuzzyfinder pyqtwebengine markdown pygments pypandoc pymmd
to install the dependencies.
To finally run the app, enter at the command line:
cd "/path/to/where/you/downloaded/sublimeless_zk"
py -3 src\sublimeless_zk.py
If you need more keybinds, you can use my code as a template. The list of actions you can bind to you can find at https://www.riverbankcomputing.com/static/Docs/QScintilla/classQsciCommand.html
in case you need keys for zoom
# zoom in
commandSet.find(QsciCommand.ZoomIn).setKey(Qt.ControlModifier | Qt.Key_Equal)
# zoom out
commandSet.find(QsciCommand.ZoomOut).setKey(Qt.ControlModifier | Qt.Key_Minus)