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

Intendation isn't preserved #36

Open
savchenko opened this issue Jan 16, 2024 · 2 comments
Open

Intendation isn't preserved #36

savchenko opened this issue Jan 16, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@savchenko
Copy link

Not sure how I haven't noticed this before, but...

recording.mp4

...can it take into account current indent level?

@LudoPinelli
Copy link
Owner

I didn't think about that since I use an autoformat on save that restore the indentation. I'll look into it!

@savchenko
Copy link
Author

If that is of any help, carved out of my old Vim config:

" Insert cut marker (https://stackoverflow.com/a/59291748)
function Cut() abort
    if &textwidth
        execute "normal! mg"
        " let l:str = input('Char: ')
        let l:str = '-'
        .s/\m\(\S\+\)$/\1 /e  " Add space after content (if present).

        " Calculate how many repetitions will fit.
        let l:lastcol = col('$')-1  " See :h col().
        if l:lastcol > 1
            let l:numstr = float2nr(floor((&textwidth-l:lastcol)/len(l:str)))
        else
            let l:numstr = float2nr(floor(&textwidth/len(l:str)))
        endif

        if l:numstr > 0
            set lazyredraw
            .s/\m$/\=(repeat(l:str, l:numstr))/  " Append repeated pattern.
            execute "normal! `g"
            :delmarks g
            set nolazyredraw
        endif
    else
        echohl WarningMsg
        echom "Cut requires nonzero textwidth setting"
        echohl None
    endif
endfunction

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

No branches or pull requests

2 participants