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

Moving over folds has undesirable behavior #1

Open
zirrostig opened this issue Mar 26, 2014 · 4 comments
Open

Moving over folds has undesirable behavior #1

zirrostig opened this issue Mar 26, 2014 · 4 comments

Comments

@zirrostig
Copy link
Owner

When dragging text over a closed fold the selection gets broken, making dragging not work as expected.

@zirrostig zirrostig added the bug label Mar 26, 2014
@zirrostig zirrostig self-assigned this Mar 26, 2014
@zirrostig
Copy link
Owner Author

Turns out vim is doing exactly what is expected, it just doesn't auto expand folds when moving text into them, causing a lot of issuses with continued schlepping.
I'm looking into having schlepp auto-expand folds when moving into them.

@zirrostig zirrostig removed their assignment Apr 7, 2014
@zirrostig zirrostig changed the title Moving over folds breaks Moving over folds has undesirable behavior Apr 7, 2014
@Ahg4goo9
Copy link

Ahg4goo9 commented Jul 6, 2016

For me, it also closes the fold when I schlepp text within an opened fold.

@knubie
Copy link

knubie commented Jul 30, 2016

@Ahg4goo9 I think this is an issue with vim itself. Try moving a line in an open fold with :m+ and you'll get the same result.

@dbmrq
Copy link

dbmrq commented Oct 5, 2016

Kind of a hack, but I did this and it seems to be working ok:

vmap <Plug>SchleppFix zagv
vmap <left>  <Plug>SchleppLeft<Plug>SchleppFix
vmap <right> <Plug>SchleppRight<Plug>SchleppFix
vmap <up>    <Plug>SchleppUp<Plug>SchleppFix
vmap <down>  <Plug>SchleppDown<Plug>SchleppFix

Edit: oops, I spoke too soon… it only works when using linewise visual mode. :/

Edit 2: It's getting even more hacky and there are plenty of problems, but in case anybody's interested, this is what I got so far to make it usable with folds. It's better than nothing, since I use them everywhere.

function! SchleppDetect(direction)
    let mode = mode()
    let command = ""
    if mode ==# 'v'
        let command .= "\<c-v>"
    endif
    let command .= "\<Plug>Schlepp" . a:direction
    if mode ==# 'V'
        let command .= "zRgv"
    endif
    return command
endfunction

vmap <silent> <expr> <Left> SchleppDetect("Left")
vmap <silent> <expr> <Right> SchleppDetect("Right")
vmap <silent> <expr> <Up> SchleppDetect("Up")
vmap <silent> <expr> <Down> SchleppDetect("Down")

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

No branches or pull requests

4 participants