zsh: Unable to bind ^q or \M-q in vi mode - zsh

My .zshrc file contains the line
bindkey -v
I'm attempting to bind ^q or \M-q to push-line, e.g.
bindkey "^q" push-line
but for some reason it isn't working.
Running `bind key -v' confirms
"^Q" push-line
But it doesn't actually do anything. Other control- mappings, such as ^r, work fine.
I can successfully map "push-line" to "\eq", but I don't like this behavior. First of all, I never use esc- type bindings, and secondly doing so binds it to control, meta, and escape, which is overkill. (Incidentally, shouldn't it only bind all of them like that with `bindkey -m'? I never set that in my .zshrc?)
So, anybody have any idea what's going on here?

These shortcuts are used by Software flow control (wikipedia)
Ctrl+S and Ctrl+Q are used to stop and resume the output of a program.
To try it:
Run while (true) ; do echo $RANDOM ; sleep 1 ; done
Press Ctrl+S, the output stop.
Press Ctrl+Q, the output resume.
(I'm not sure the program is stopped like with Ctrl+Z, i think it is stuck by lack of outputting. Ctrl+C to kill the program.)
These shortcuts take over your shortcuts, but if you disable this flow control feature, it could work.
You can learn how to disable it in How to unfreeze after accidentally pressing Ctrl-S in a terminal? - Unix and Linux.
Try it and tell us.

Related

Closing multiple iTerm2 tabs makes zsh_history lose most of the history

I use zsh 5.8 (oh-my-zsh + my custom configs) with iTerm2.
I want every zsh instance to store the command to the history every time I type it and share the history with the others.
It basically works as I want, but the problem is, if I (manually) quit iTerm2 with multiple tabs open (e.g. so that I can recover those tabs after reboot), the zsh_history file loses most of its content and contains only the first N commands.
My guess is the zsh instances kind of compete with each other in the last moment.
HISTSIZE and SAVEHIST are set largely enough (10000000).
setopt prints:
alwaystoend
autocd
autopushd
noclobber
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histfcntllock
histignoredups
histignorespace
histverify
incappendhistory
interactive
interactivecomments
login
longlistjobs
monitor
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle
Is there any way I can prevent this from happening?
EDIT: After seeing the comment, I disabled inc_append_history, but it's happening again.
EDIT2: Disabled appendhistory as well, but still the same.
EDIT3: After manually unsetting histsavebycopy (i.e., nohistsavebycopy), looking good so far.
EDIT4: Since the last change (EDIT3), I've experienced zsh: corrupt history file once.
EDIT5: Lost some history even without the corrupt history file error.

Commands not executing on keybind, but are executing from command pallet

Got an issue with keymapping commands:
https://www.youtube.com/watch?v=d5nrEO_t7Wo
As you can see in the video, when I call the commands by keyboard shortcut:
On the first attempt - the function isn't called.
On the second attempt - the function is called.
Where as, when I call the commands via the command pallet, the commands are called even on the first attempt. Not shown in the video, I can call the commands from the command pallet more than once without fail.
This leeds me to believe there is something wrong with my keymap.coffee:
'.editor:not(.mini)':
'shift-cmd-h': 'hex:view'
'alt-down':'editor:add-selection-below'
'alt-up':'editor:add-selection-above'
'.editor':
'cmd-k':'jxa:compile'
'shift-cmd-k':'jxa:compileApp'
'cmd-u':'jxa:execute'
However I can see nothing clearly wrong here... So perhaps there's something wrong with my init.js?
https://github.com/sancarn/JXA-Compile/blob/master/src/init.js
Any ideas?
This was solved by DamnedScholar here.
Okay, no. It's because cmd-k is bound to so many things. Go into Settings -> Keybindings and search for it and you'll see a lot of different things attached to it that are all bindings with multiple key presses. So when you press cmd-k, Atom waits to see what your next key press will be. You should consider using something different for jxa:compile.

Is there a way to clear the message below the command line (zle -M "message") if a different widget runs?

I have a zsh/zle widget that is usually/often run multiple times in a row. I would like to display a message using zle -M but if a widget OTHER than mine runs I would like to clear the message. Is there a way to do that?
I've poured through the docs but I don't see a hook or anything else to pull this off. The only thing that occurred to me is replace every key binding that bindkey reports with a head patch wrapper and then restore them if it gets hit but I think that would cause problems with widgets who look at $WIDGET, $LASTWIDGET, etc.

How to set user command in Qt Fakevim?

(1) For example, I want to set map gd g* in Qt's Fakevim like below but failed.
(2) And also I'd like to set F3 as the save command, how to do it?
(3) In Fakevim, it provides an option "Read .vimrc", but where to find the file .vimrc?
Thank you!
It doesn't look like there is a lot of documentation for FakeVim, so official sources might not exist. Most of this was obtained by experimentation.
If you want to dig deeper, I guess there's no source as official as the actual source: http://qt.gitorious.org/qt-creator/qt-creator/blobs/0809986e501415fe2c8508800b94b5b3169dc048/src/plugins/fakevim/fakevimplugin.cpp
User commands
First off, realize that in Tools>Options>FakeVim>User Command Mapping, you're only setting what your user actions will perform, not how you perform them.
By default, user command #1 is triggered by pressing Alt-V, then 1.
Alt-V, then 2, triggers user action #2, and so on.
You can change the keyboard shortcuts through the general QtCreator configuration interface, under Tools>Options>Environment>Keyboard. There is a "FakeVim" section with all the user actions listed. Select your user action of choice, press the little "erase" icon in the input field under "Shortcut", then press your desired shortcut key, which should appear in the input field.
Second, to finish a command where you would normally press enter, you should literally type in <CR> after the commands. You also need to enter in ':' to enter command mode.
So if you wanted to map the vim save command, ":w", to F3 via FakeVim, you would:
Go to Tools>Options>FakeVim>User Command Mapping.
Enter ":w<CR>" as one of the user commands (say #7).
Go to Tools>Options>Environment>Keyboard.
Find the FakeVim action "UserAction7".
Set F3 as a shortcut for it.
Now, every time you're in the editor, you should be able to click F3 and have the FakeVim :w command execute, which will save your file.
Note that there is also an option to set a shortcut for "Save" directly in the QtCreator keyboard settings, so for this particular shortcut you don't actually need to go through FakeVim.
Setting shortcuts for other vim commands should be similar. Note that you're restricted to the subset of vim commands that FakeVim implements. Refer to the source, linked above, for checking any particular command you're wondering about.
Vimrc file
On Linux this would be ~/.vimrc, a file in the user's home directory. I presume you're asking about Windows.
The best source I can find is this bug report about it being hard to use Fakevim's vimrc on Windows: https://bugreports.qt.io/browse/QTCREATORBUG-8748
Following that, the file Fakevim looks for is ".vimrc" in %USERPROFILE% (you can enter a name like that in Explorer to go to the folder). However, it's tricky to access a file with a name like that on Windows. (Thus why the real vim uses '_vimrc' on Windows -- but FakeVim apparently doesn't, at least at the moment.)
Here is a superuser page with workarounds for how to create such files on Windows: https://superuser.com/questions/64471/create-rename-a-file-folder-that-begins-with-a-dot-in-windows

Creating new shortcut in notepad++

I am trying to add a shortcut or a button in notepad++ to call an external program on the file I am currently editing.
For example, let's say I have the program "analyzer.jar". I would like to create a button (or shortcut) in notepad++ that would directly run the command "cmd -K java -jar analyzer.jar "$(FULL_CURRENT_PATH)".
Since I haven't found any solution yet, any help would be deeply appreciated :).
Well, in fact I found how easy it is to create a shortcut for a command:
Go in the menu and select "Run &rightarrow; Run..." (or press f5)
Type your command
Click on "Save", and select the keyboard shortcut of your choice
Sometimes, when you look for complicated solutions, you don't see the simple ones...

Resources