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

Boost buffer content replace #37

Merged
merged 2 commits into from Mar 27, 2018

Conversation

mluts
Copy link
Contributor

@mluts mluts commented Mar 27, 2018

:substitute hangs my machine for 5-15 seconds on large files, this works much faster

let content = type(a:content) == v:t_list ? a:content : split(a:content, "\n")

if getline(1, '$') != content
%del
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

@venantius
Copy link
Owner

Definitely appreciate the speedup. Would love to understand a bit more about what exactly the changes do since it's been a while since I wrote this. Mind breaking it down a bit more for me?

@mluts
Copy link
Contributor Author

mluts commented Mar 27, 2018

@venantius :0,substitute/\_.*/\=formatted_output/g works frustratingly slow, perhaps because whole file becomes matched using regexp .*.

%del is actually vim's :[range]delete command (see :help :delete)

setline()

            When {text} is a List then line {lnum} and following lines     
            will be set to the items in the list.  Example:                
                    :call setline(5, ['aaa', 'bbb', 'ccc'])                
            This is equivalent to:                                         
                    :for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]    
                    :  call setline(n, l)                                  
                    :endfor

@venantius
Copy link
Owner

Great, thanks!

@venantius venantius merged commit f4bbc04 into venantius:master Mar 27, 2018
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

Successfully merging this pull request may close these issues.

None yet

2 participants