Alt keys in xdotool? - linux

How to simulate left and right alt key presses with xdotool?
Have tried variations of the following in command line and scripts:
xdotool keydown Alt_R key Alt_L ; sleep 1 ; xdotool keyup Alt_R
xdotool key Alt_R+Alt_L ; sleep 1 ; xdotool keyup Alt
xdotool keydown Alt_R+Alt_L ; xdtool keyup Alt_R+Alt_L
xdotool keydown Alt_R ; xdotool keydown Alt_L ; xdotool keyup Alt_R ; xdotool keyup Alt_l
etc, etc, ad nauseum.
Phrasing doesn't seem to matter; unable to simulate both left and right alt keys together. Anybody know the "proper" way to construct this?

Related

How to select first item in popup menu and close menu in a single keybind for autocomplete in nvim?

I'm using coc.nvim for autocomplete and when the popup menu appears, I'd like Tab to select the first item and close the menu. At the moment I've keybinded Tab to <C-n><CR>, but the <CR> actually puts in a line return which is not what I want.
inoremap <expr> <Tab> pumvisible() ? "\<C-n><Space>" : "<Tab>"
I found the answer the coc.nvim's example docs:
https://github.com/neoclide/coc.nvim/blob/e1a4ce4d95d1d89b6dd31019cc4387425aa09b86/doc/coc.txt#L892-L909
inoremap <silent><expr> <TAB>
\ pumvisible() ? coc#_select_confirm() :
\ coc#expandableOrJumpable() ?
\ "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:coc_snippet_next = '<tab>'
Works like an absolute charm.
Try inoremap <expr> <Tab> pumvisible() ? coc#_select_confirm() : "<Tab>".
After struggling for so long and trying these things I realised it works out the box fine.
To select the first item in the dropdown list press: ctrl+y.
Press: ctrl+n select the next item in the drop down list.
Press: ctrl+p to select the previous item in the drop down list.
To use tab and shift tab as well to navigate next and previous items see the documentation.
To use tab to select first item in the drop down list below the above documentations config:
inoremap <expr> <TAB> pumvisible() ? "\<C-y>" : "\<C-g>u\<TAB>"

Vim vertical resize shortcut

I would like to set a shortcut to resize the width of two panes:
:vertical resize +2
I would like to map this to [option] + (in other words, shift + option + "+). I am on a mac. I tried doing the following. How would I add in this shortcut for a nnoremap ?
you can do this without having to switch to the ex command line:
To change vertical height:
[n] --> ctrl + w --> [+ | -]
And horizontal:
[n] --> ctrl + w --> [< | >]

Set ; at the end of the line in VIM-MODE-PLUS Atom Editor

How I have to config Vim so with just pressing (in normal mode) ; the ; is set at the end of the line?
So
console.log('foo')
Becomes
console.log('foo');
Wherever you have the cursor in the line.
I know the combination would be shift + A + ;+Esc

understanding X keyboard mappings, audio keys and fluxbox

So, I'm trying to set up fluxbox to work with my Dell keyboard which has a bunch of extra keys on it for web browsing and audio control.
I did this in my .fluxbox/keys file, and it's mostly working to control cmus.
# Music in cmus
XF86AudioPlay :Exec cmus-remote --pause
XF86AudioPause :Exec cmus-remote --pause
XF86AudioStop :Exec cmus-remote --stop
XF86AudioNext :Exec cmus-remote --next
XF86AudioPrev :Exec cmus-remote --prev
But, the stop key doesn't work. So I use showkey on it...
keycode 166 press
keycode 166 release
and it tells me that the stop key is keycode 166. According to xmodmap...
xmodmap -pke | grep 166
keycode 166 = XF86Back NoSymbol XF86Back
that is XF86Back, but mapping that in my keys file doesn't work either. More disturbing, the play/pause key, which is already working, is supposedly keycode 164, which xmodmap says is...
xmodmap -pke | grep 164
keycode 164 = XF86Favorites NoSymbol XF86Favorites
when I expectted it to be XF86AudioPlay, which is supposedly...
xmodmap -pke | grep AudioPlay
keycode 172 = XF86AudioPlay XF86AudioPause XF86AudioPlay XF86AudioPause
keycode 208 = XF86AudioPlay NoSymbol XF86AudioPlay
keycode 215 = XF86AudioPlay NoSymbol XF86AudioPlay
one of those. So...
...what's going on? Why is play/pause working if it's the wrong keycode, and is it the wrong keycode? Being a Dell keyboard, I expect all kinds of problems, since Dell in their infinite wisdom always liked to deviate from standards.
Thanks,
Mike

change the keymapping under linux

Target
make my system keymapping works in a way like vim;
I want the cursor move down when pressing windowsKey + j
I want the cursor move up when pressing windowsKey + k
I want the cursor move right when pressing windowsKey + l
I want the cursor move left when pressing windowsKey + h
Solution
Using xmodmap tool
Result
Failed.
Here I'll give you some information:
I try to change the keymapping using this command under the shell
xmodmap -e "keycode 44 = 1 2 3 4 5 6 7 8"
This command succeed, and the j and J is mapped to 1 and 2
But that's not enough,the windowsKey + j is not changed at all.
When pressing windowsKey + j, it gives me an 1 insted of 7
that's not what I want
Specifics:
OS:Centos 6.4 (64 bit) with gnome 2.28.2
And the output of xmodmap -pm
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
Question
If there is other ways to change the keymapping or you can tell me where I'm wrong
Please let me know
The reactions for keyboard events are specific for whatever programs are interpreting them.
If you're looking for a way to make command line editing work like vi, then you might get closer to what you want, with Bourne Again Shell at least, with set -o vi and then mapping the windows keys to escape (in order to enter vi edit mode) with xmodmap -e 'keycode 133 = Escape' -e 'keycode 134 = Escape'.
For other programs there are other ways to make this work, but cursor movement in v

Resources