Houl / repmo-vim

Repeat motions [for which a count was given]
38 stars 5 forks source link

repmo not working with ftplugin #12

Closed jacksonsc007 closed 3 months ago

jacksonsc007 commented 3 months ago

Sorry to bother you. @Houl

I am new to vim and I want to repeat motions for vim, so I end up here.

After I deploy repmo-vim & refrftsc-vim, j k <c-e> <c-y> work all well, but the ]] could not be repeated.

My vim configuration tree & vimrc is as follows:

  1. vim configuration:
    
    ink@~/.vim[24-0602-09:43] tree ~/.vim
    /home/ink/.vim
    └── plugin
    ├── refrftsc-vim
    │   ├── after
    │   │   └── ftplugin
    │   │       └── erlang.vim
    │   ├── autoload
    │   │   ├── motpat.vim
    │   │   └── nwo
    │   │       ├── gvmap.vim
    │   │       └── var.vim
    │   ├── doc
    │   │   ├── motpat.txt
    │   │   └── tags
    │   ├── ftplugin
    │   │   └── python.vim
    │   ├── plugin
    │   │   └── perl-nextmethod.vim
    │   ├── README.markdown
    │   └── vimrc.vim
    └── repmo-vim
        ├── autoload
        │   └── repmo.vim
        └── README.markdown
2. vimrc:
```vim
:noremap <expr> h repmo#SelfKey('h', 'l')|sunmap h
:noremap <expr> l repmo#SelfKey('l', 'h')|sunmap l

" if you like `:noremap j gj', you can keep that:
:map <expr> j repmo#Key('gj', 'gk')|sunmap j
:map <expr> k repmo#Key('gk', 'gj')|sunmap k

" repeat the last [count]motion or the last zap-key:
:map <expr> ; repmo#LastKey(';')|sunmap ;
:map <expr> , repmo#LastRevKey(',')|sunmap ,

:noremap <expr> <C-E> repmo#SelfKey('<C-E>', '<C-Y>')
:noremap <expr> <C-Y> repmo#SelfKey('<C-Y>', '<C-E>')

repos are directly cloned. And I delete ftplugins for other languages except python.

  1. : verbose map ]] gives:
    nox]]           @<Plug>]]-motion                                                                                                                                                                                      
        Last set from ~/.vim/plugin/refrftsc-vim/ftplugin/python.vim line 42
    nox]]            repmo#Key('<Plug>]]-motion', '<Plug>[[-motion')
        Last set from ~/.vim/plugin/refrftsc-vim/vimrc.vim line 4

As I am a novice, some serious but naive mistakes are inevitable.

It will be great if you got time for my issue. Thanks.

Houl commented 3 months ago

Make [[ and ]] use repmo:

  1. prevent direct mapping of [[ and ]] in the ftplugin:
    " in the vimrc
    :let g:no_python_maps = 1
  2. globally map [[, ]] as follows:
    
    " in the vimrc
    map <expr> [[ repmo#Key('<Plug>[[-motion', '<Plug>]]-motion')|sunmap [[
    map <expr> ]] repmo#Key('<Plug>]]-motion', '<Plug>[[-motion')|sunmap ]]

"map ][ repmo#Key('][-motion', '[]-motion')|sunmap ][ "map [] repmo#Key('[]-motion', '][-motion')|sunmap [] "map [m repmo#Key('[m-motion', ']m-motion')|sunmap [m "map ]m repmo#Key(']m-motion', '[m-motion')|sunmap ]m "map [M repmo#Key('[M-motion', ']M-motion')|sunmap [M "map ]M repmo#Key(']M-motion', '[M-motion')|sunmap ]M "map [" repmo#Key('["-motion', ']"-motion')|sunmap [" "map ]" repmo#Key(']"-motion', '["-motion')|sunmap ]"

jacksonsc007 commented 3 months ago

Problems solved!

Really appreciate your prompt response and long-term perseverance in maintaining the repository!