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
Related
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?
If your Vim settings include 'r' in 'formatoptions' (default) it will automatically insert the current comment leader after hitting [Enter] in insert mode, but this can be undesirable for abbrevs that expand to a single-line comment in languages that don't have separate single/multi-line comment characters.
How do I stop getting this when I press [Enter] after typing the abbrev characters?
# ========
#
This is what I did:
" Eat one character matching the given regex from the input stream, e.g. at
" the end of an abbr expansion. (From :help abbreviations)
func Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
set pastetoggle=<F12>
iabbr <silent> sep # ========<F12><CR><F12><C-R>=Eatchar('\r')<CR>
This replaces the user's [Enter] key press with a generated one surrounded by generated key presses that turn paste mode off before and back on afterwards. The final <C-R> completes the <C-R>= sequence.
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
I have this function in my vimrc to jump to the first nonblank character on the line:
function! SmartHome()
let s:col = col(".")
normal! ^
if s:col == col(".")
normal! 0
endif
endfunction
This works well outside of a tmux session.
But inside of a tmux session it will just jump to the first character on the line - which is wrong!
I have mapped this function this way:
" smart home function
nnoremap <silent> <Home> :call SmartHome()<CR>
inoremap <silent> <Home> <C-O>:call SmartHome()<CR>
How can I solve this?
I could solve this problem by removing the following line from my .bashrc file
export TERM=xterm-256color
This works since xterm and the screen "like" protocol from tmux does not send/expect the same values for the HOME key:
$ tput -T screen khome | xxd
0000000: 1b5b 317e .[1~
$ tput -T xterm khome | xxd
0000000: 1b4f 48 .OH
I've got a cntrl c and cntrl v mapped to xclip, however its a hassle to have to remember to use instead of regular y and p. Is there a way to alias the two or send contents of y and p to xclip, so I can just use y and p for all copy and pasting?
vmap <C-c> y:call system("xclip -i -selection clipboard", getreg("\""))<CR>:call system("xclip -i", getreg("\""))<CR>
nmap <C-v> :call setreg("\"",system("xclip -o -selection clipboard"))<CR>p")")")"))
Are you trying to use the X clipboard for all copy and pastes? If so, a good alternative to xclip is to make sure you're using a vim with X support (it's really easy to compile Vim if your version doesn't have it) and then add the following to your vimrc:
set clipboard=unnamed
All yanks and deletes will then automatically go to the * register (which is the X selection register).
Instead of setting clipboard=unnamed, you can also use the X selection register for a single operation by using (e.g.)
"*yw
"*yy
"*ya(
or whatever.
Obviously, this doesn't answer your question as to how to use xclip, but hopefully it offers an alternative approach.
I don't know if this is an ideal solution, but it works.
set clipboard=unnamedplus
function! ClipboardYank()
call system('xclip -i -selection clipboard', ##)
endfunction
let vlcb = 0
let vlce = 0
function! ClipboardPaste(mode)
if (a:mode == "v")
call cursor(g:vlcb[0], g:vlcb[1]) | execute "normal! v" | call cursor(g:vlce[0], g:vlce[1])
endif
let ## = system('xclip -o -selection clipboard')
endfunction
" replace currently selected text with default register without yanking it
vnoremap <silent>p "_dP
vnoremap <silent>y y:call ClipboardYank()<CR>
vnoremap <silent>d d:call ClipboardYank()<CR>
nnoremap <silent>dd dd:call ClipboardYank()<CR>
nnoremap <silent>p :call ClipboardPaste("n")<CR>p
vnoremap p :<C-U>let vlcb = getpos("'<")[1:2] \| let vlce = getpos("'>")[1:2] \| call ClipboardPaste("v")<CR>p
You can also set clipboard=unnamedplus to use the “+” register by default. Using it, I did yy in my .vimrc and then pasted that line here by ctrl-V ;)