Using PhpStorm IdeaVim, I can't use shift+arrow keys to select words

后端 未结 8 850
有刺的猬
有刺的猬 2021-01-30 13:11

I am using PhpStorm 7.1.2 with IdeaVim plugin.

When in Insert mode, I want to select words using Shift + ArrowKey. However, this IdeaVim plugin seems to be

相关标签:
8条回答
  • I would create a ~/.ideavimrc with the following lines

    nmap <S-Up> v<Up>
    nmap <S-Down> v<Down>
    nmap <S-Left> v<Left>
    nmap <S-Right> v<Right>
    vmap <S-Up> <Up>
    vmap <S-Down> <Down>
    vmap <S-Left> <Left>
    vmap <S-Right> <Right>
    imap <S-Up> <Esc>v<Up>
    imap <S-Down> <Esc>v<Down>
    imap <S-Left> <Esc>v<Left>
    imap <S-Right> <Esc>v<Right>
    

    It makes my code select text in the same way.

    0 讨论(0)
  • 2021-01-30 13:47

    If you have a binding to enable / disable IdeaVIM, you can get shift-arrow selection by temporarily disabling IdeaVIM, then using shift-arrow selection, then re-enabling IdeaVIM.

    The action in the Keymap dialog is called "Vim Emulator", and in the "Default" keymap it is bound to V; in "Mac OS X 10.5+" keymap it is bound to V.

    You can look up shortcuts for your keymap either in the Preferences => Keymap dialog, or with the Help => Find Action... menu.

    (Note: is also called "option" or "alt"; is the "command" key on a Mac.)

    0 讨论(0)
  • 2021-01-30 13:48

    create ~/.ideavimrc file with the following lines

    nnoremap <S-Left> :action EditorLeftWithSelection<CR>
    nnoremap <S-Right> :action EditorRightWithSelection<CR>
    nnoremap <S-Up> :action EditorUpWithSelection<CR>
    nnoremap <S-Down> :action EditorDownWithSelection<CR>
    
    inoremap <S-Left> <C-O>:action EditorLeftWithSelection<CR>
    inoremap <S-Right> <C-O>:action EditorRightWithSelection<CR>
    inoremap <S-Up> <C-O>:action EditorUpWithSelection<CR>
    inoremap <S-Down> <C-O>:action EditorDownWithSelection<CR>
    
    0 讨论(0)
  • 2021-01-30 13:48

    It appears to not be possible out of the box. However, it is not hard to hack the plugin to remove the hard-coded vim actions for shift + arrow keys, as long as you have ideavim. This has the effect of letting the default behaviours be used.

    Steps:

    1. git clone https://github.com/JetBrains/ideavim.git
    2. Open the newly cloned project in ideavim.
    3. Set up the intellij sdk dependency in Files / Project Structure (if necessary).
    4. Edit ideavim/src/com/maddyhome/idea/vim/RegisterActions.java.
    5. Remove all key actions that redefine shift+arrow key): :s%/^.*KeyEvent.VK_\(KP_\)\?\(LEFT\|RIGHT\|UP\|DOWN\), KeyEvent.SHIFT_MASK.*$//.
    6. Rebuild using the ant tasks clean compile dist.
    7. Reinstall the plugin via Options / Plugins / Install Plugin From Disk and locate ideavim/out/dist/ideavim-xx-dev.zip
    0 讨论(0)
  • 2021-01-30 13:52

    Disable Vim emulator 2 ways:

    1.- Ctrl+alt+v / Cmd+alt+v
    2.- Tools (menu) -> Vim emulator
    
    0 讨论(0)
  • 2021-01-30 13:55

    I've hacked the latest version of IdeaVim to not bind to the arrow keys. I found keymodel didn't quite do what I wanted. I grew too used to Joe Thomas's hack in the previous version to change my ways.

    My hacked version can be found here: https://github.com/shaunpatterson/ideavim

    0 讨论(0)
提交回复
热议问题