Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking macro (nvim, didn't try on vim) #138

Open
davidsu opened this issue Apr 20, 2017 · 5 comments
Open

breaking macro (nvim, didn't try on vim) #138

davidsu opened this issue Apr 20, 2017 · 5 comments

Comments

@davidsu
Copy link

davidsu commented Apr 20, 2017

minimal vimrc:

call plug#begin('~/.config/nvim/plugged')
Plug 'haya14busa/incsearch.vim'                             "  Improved incremental searching for Vim
call plug#end()
map /  <Plug>(incsearch-forward)
let g:incsearch#auto_nohlsearch = 1

file

bind-key -n C-k if-shell "$is_vim" "send-keys C-k"  "select-pane -U"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k"  "select-pane -U"

macro

0f dt f v/sele<CR>3hdj0

notice I wrote <CR> here, it's actually a press of the enter key

it seems to execute something like

0f dt f v/sele<CR>3hdv$

instead

@davidsu davidsu changed the title braking macro (nvim, didn't try on vim) breaking macro (nvim, didn't try on vim) Apr 20, 2017
@haya14busa
Copy link
Owner

I don't understand the reproduction steps.
You don't use macro (q), right?

@maple-leaf
Copy link

maple-leaf commented May 3, 2017

Macro will break if using incsearch with easymotion intergration, steps to reproduction:

  1. qa
  2. /search
  3. cw
  4. type something
  5. q
  6. @A

And related config below:

Plug 'easymotion/vim-easymotion'
Plug 'haya14busa/incsearch.vim' " improved search, fuzzy search, search index and count
Plug 'haya14busa/incsearch-easymotion.vim'
Plug 'haya14busa/incsearch-fuzzy.vim'

function! s:easyMotionConfig()
    let g:EasyMotion_do_mapping = 0 " Disable default mappings

    " Jump to anywhere you want with minimal keystrokes, with just one key binding.
    " `s{char}{label}`
    nmap s <Plug>(easymotion-overwin-f)
    " or
    " `s{char}{char}{label}`
    " Need one more keystroke, but on average, it may be more comfortable.
    nmap s <Plug>(easymotion-overwin-f2)

    " Turn on case insensitive feature
    let g:EasyMotion_smartcase = 1

    " JK motions: Line motions
    map <Leader>j <Plug>(easymotion-j)
    map <Leader>k <Plug>(easymotion-k)
endfunction
call s:easyMotionConfig()

" You can use other keymappings like <C-l> instead of <CR> if you want to
" use these mappings as default search and somtimes want to move cursor with
" EasyMotion.
function! s:incsearch_easymotion_intergration(...) abort
  return incsearch#util#deepextend(deepcopy({
  \   'modules': [incsearch#config#easymotion#module({'overwin': 1})],
  \   'keymap': {
  \     "\<CR>": '<Over>(easymotion)'
  \   },
  \   'is_expr': 0
  \ }), get(a:, 1, {}))
endfunction
function! s:incsearch_easymotion_intergration_with_fuzzy(...) abort
    return extend(copy({
                \   'converters': [incsearch#config#fuzzyword#converter()],
                \   'modules': [incsearch#config#easymotion#module({'overwin': 1})],
                \   'keymap': {"\<CR>": '<Over>(easymotion)'},
                \   'is_expr': 0
                \ }), get(a:, 1, {}))
endfunction

function! s:incsearchConfig()
    " dont work well with macros when using easymotion with incsearch
    noremap <silent><expr> /  incsearch#go(<SID>incsearch_easymotion_intergration())
    noremap <silent><expr> ?  incsearch#go(<SID>incsearch_easymotion_intergration({'command': '?'}))
    noremap <silent><expr> g/  incsearch#go(<SID>incsearch_easymotion_intergration_with_fuzzy())
    noremap <silent><expr> g?  incsearch#go(<SID>incsearch_easymotion_intergration_with_fuzzy({'command': '?'}))
endfunction
call s:incsearchConfig()

@haya14busa
Copy link
Owner

I don't understand what does "Macro will break" means, but you should not use easymotion in macro in the first place. The target label of easymotion may changes depending on the buffer state.

@maple-leaf
Copy link

OK. For now, I disable easymotion for search. I think updating readme about this after easymotion intergration part will be good.

@blankname
Copy link

Maybe related:
init.vim

call plug#begin('~/.config/nvim/plugged')
  Plug 'haya14busa/incsearch.vim'
call plug#end()

map /  <Plug>(incsearch-forward)

test.txt

call plug#begin('~/.config/nvim/plugged')
call plug#begin('~/.config/nvim/plugged')

run
nvim -u init.vim test.txt
press
qqv/(<CR>dqj@q

Expect both lines to be the same ('~/.config/nvim/plugged')), get this instead:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants