key-binding interview questions
Top key-binding frequently asked interview questions
I use bash in Windows, both in Cygwin and in Git Bash (part of Git for Windows). In bash unlike in the Windows cmd.exe
Esc does not clear the line, only Ctrl + U. How can I make clear the line also?
Thanks!
Source: (StackOverflow)
I'm trying to figure out how to bind ctrl-tab to cycle through all open windows, I've tried:
bind-key -n C-Tab select-window -t :.+
which says Unknown key.
What am I missing?
Note: I don't want to use my prefix keys prior to pressing ctrl-tab, I just want ctrl-tab to cycle through all the panes.
Source: (StackOverflow)
I'm trying to do the right thing and put my key bindings into ~/.inputrc
.
However, it turns out that I have to change
bind '"\e\C-j":"\e[1~quiet \e[4~\n"'
into
"\e\C-j": "\eOHquiet \eOF\n"
Now \eOH
(nav-block-pos1 bound to beginning-of-line
) and \eOF
(nav-block-end bound to end-of-line
) are themselves bindings in my configuration which I possibly cannot always rely on.
So the main question is why does binding to num-block-pos1 (\e[1~
) and num-block-end (\e[4~
) work with bind
but not in my ~/.inputrc
?
Edit:
The whole thing is getting even more complicated, now that I realized that \e\C-j
only works for Gnome Terminial (or probably xterm as well, who knows...).
For my TTY it has to be
"\e\C-m": "\e[1~_quiet \e[4~\n"
So is it that various VTs have different implementations of how to interpret keys or what?
Source: (StackOverflow)
In windows 8 I used to remap my capslock key to control using the registry script
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
After having upgraded to window 10, this does not work anymore. How can it be done?
Source: (StackOverflow)
This question already has an answer here:
How can I remap keyboard keys in windows 8.1? I'm looking for a simple utility which will modify registry and would not require running at startup. I tried sharpkeys but, it does not seem to work in windows 8.1. Any other suggestions? Or a simple how-to tutorial for windows 8.1?
Edit: Keytweak isn't working either. Actually I want to map an unused key to function key (fn) and neither sharpkeys nor keytweak detect the keystroke for that key.
Thanks
Source: (StackOverflow)
In bash the Ctrl+r command is very useful, I type Ctrl+r whatever
and it searchs my history for commands containing the word whatever
. But if I type whatever
and realize that I would like search that word and hit Ctrl+r nothing happens.
Is there a way hitting a key and having it behaving as if I had typed Ctrl+r whatever
instead of whatever
Ctrl+r?
I have the following in my .inputrc
:
"\C-p": history-search-backward
but this only works if the beginning of the line is the same.
Source: (StackOverflow)
I am able to map the key combination Right Alt+Left Arrow with <a-left>
or by <m-left>
. But I am not able to map the Left Alt key.
Is there a way to do that?
Edit:
Just to clarity <a-left>
means Alt+Left Arrow.
The important question here is what is difference between Left Alt and Right Alt from the perspective of keymappings in Vim?
Source: (StackOverflow)
In my .emacs
file, I want to add a key binding for a specific major mode (setting coffee-compile-file
to C-c C-c in coffee-mode).
I've found a lot of instructions on using local-set-key
and global-set-key
, so I can easily add this binding once I've opened a file in coffee-mode, but it would be nice for this to be handled by .emacs
.
Source: (StackOverflow)
Using polish language on Windows 8.1, comma is the default decimal seperator on numerical keyboard. Is there a way to change it to dot?
I wouldn't like to change it in Excel or some other program, but permanently rebind that key to dot. Can I do that?
Source: (StackOverflow)
I use Mac OS X and Arch Linux and occasionally log into FreeBSD and Debian servers by ssh. My favoured tools are zsh, ssh, tmux, git, vim and irssi. I use iTerm2 on Mac OS X and unicode-rxvt on Arch Linux, where I also use Xmonad as window manager.
Currently Ctrl+a+n shifts to the next window in tmux, Alt+right shifts to the next in irssi, Cmd+right shifts to the next tab in iTerm2, Ctrl+w+w shifts to the next buffer in vim and so on. Basically it's just a mess and even though some of these sit in the muscle memory most don't. I'm looking for what could be a consistent keybinding scheme.
In my mind I figure Cmd/Super/Win ought to be used by the OS desktop environment and/or window manager, Alt would be tmux and Ctrl would be vim and irssi. That is going from right to left on the keyboard; Cmd, Alt, Ctrl, and in a somewhat hierarchical way, OS/DE/WM, multiplexer, editor/irc client.
Hence, something like this:
Cmd+Left/+Right - Switch workspace (Xmonad)
Alt+Left+/Right - Switch tmux window
Ctrl+Left/+Right - Switch irssi window/vim buffer
Cmd+1 - Switch to workspace 1 (Xmonad)
Alt+1 - Switch to tmux window 1
Ctrl+1 - Switch to irssi window 1/vim buffer 1
Would this be viable? If not, what uniform keybindings could be used?
UPDATED
I drew a picture (the colours are horrible, I know) to illustrate what I had in mind. I use Dvorak and replaced vim hjkl movement with dhtn - I'll write left/down/up/right to have it make sense for those who don't use vim. Let's keep it to iTerm2 rather than the entire OS X desktop environment (as well as Gnome and KDE). Basically it comes down to this:
cmd+left/right/number for workspaces in Xmonad (or whatever window manager you like)
alt+left/right/number for windows in tmux
ctrl+alt+left/down/up/right/number for buffers in vim
ctrl+alt+left/right/number for windows in irssi
ctrl+left/down/up/right for home/pg down/pg up/end in vim, irssi and zsh

In OS X ctrl+left/down/up/right already works like the above, and alt+left/right moves the cursor by word as opposed to just left/right which moves it by character.
Wouldn't this be fairly logical and intuitive? Am I missing something (conflicting keybindings) or is this doable?
Source: (StackOverflow)
The Home,End keys are at the top row in my laptop, and I use them most while selecting the entire line by pressing (Shift+Home, Shift+End) - it is very inconvenient. On the other hand, "PageUp, PageDown" keys are just below the Shift Key, and I don't use them at all.
Can I interchange my "PageUp" key with "Home" key and "PageDown" key with "End" key?
Is this possible using some software?
Source: (StackOverflow)
bash home/end/delete key inserting tilde, or if preceded by escape key, [1~
say I type echo hellp, move cursor to hel|lp and type delete, and bam, i got ~tilde
say I type echo hellp, move cursor to hel|lp and type esc then delete, and bam, i got [3~
$ echo hel~lp
hel~lp
$ echo hell[3~o
hell[3~o
~
$ bash --version
GNU bash, version 3.1.17(1)-release (i686-pc-msys)
Copyright (C) 2005 Free Software Foundation, Inc.
what i want is cmd.exe like behaviour,
I want Esc to clear the current line / buffer
I want Home to move cursor to start of line before first character
I want End to move cursor to end of line before first character
I want delete to delete the next character (right of cursor) from current line/buffer
What do I have to edit to fix this?
Is this default on your bash ?
update: i'm on a windows machine running a windows program, sh.exe ( as you can see above GNU bash), compiled with mingw for msys
$ uname -s -m -o
MINGW32_NT-5.1 i686 Msys
Source: (StackOverflow)
I would like scrolling up to be equivalent to c-y c-y c-y
, and scrolling down to be equivalent to c-e c-e c-e
. The documentation here seems to suggest that this should already be the case, or I can work around it by putting this in my .vimrc
:
map <ScrollWheelUp> <C-Y>
map <S-ScrollWheelUp> <C-U>
map <ScrollWheelDown> <C-E>
map <S-ScrollWheelDown> <C-D>
Neither of these solutions seem to work. I am using vim
from the terminal in Ubuntu 11.10.
Source: (StackOverflow)
The MacBook trackpad is a marvellous thing. Assuming that one uses the 'tap to click' functionality exclusively (including the double tap to click-hold within Usability settings) as I do, the physical click button that sits behind the whole of the actual glass hardware can find itself going completely unused. This happened to me, I realised, after letting a friend use the machine to check her email; I heard that solid, subtle clunk for the first time in months.
What I would really like to do is bind this currently redundant button to something that will be used regularly. And, for my workflow at least, this something is Launchpad.
There are two main reasons for this.
I get a hell of a lot of use out of launchpad. I do not use my dock as an application launcher; it instead shows a list of active applications (as per http://www.macgasm.net/2011/04/29/show-active-applications-mac-os-dock-2d-time/) so my launchpad is my main launcher and really the centre of my OS. However, the four-finger pinch gesture used to access the launchpad does not work for me 100% of the time. I'd say it works 95% of the time which, considering I would happily perform said gesture 20 times in a session, at least once per session it leaves me momentarily frustrated. I require a better, more consistent gesture.
I use an iPhone. The physical click to access Springboard has been one of my favourite things about that device from iOS year zero. I think the idea of mirroring this physical click to the mac trackpad and Launchpad would be a beautiful example of cross-device consistency and would instantly become of second nature.
I have Googled around a little and found a few examples of GUI software that can modify inputs, but none that boast the ability to distinguish tap-to-click from click-to-click, if you follow. How low-level would I have to dig to intercept this distinction?
Any advice or direction would be hugely appreciated.
Source: (StackOverflow)
I logged in on one of hosting provider servers and noticed ALT + left and ALT + right moved between words in a shell prompt in GNU Screen.
What kind of key bindings I need to configure and where to get this behavior to my local OS X zsh running in iTerm2?
Source: (StackOverflow)