vim-table-mode icon indicating copy to clipboard operation
vim-table-mode copied to clipboard

Very slow for a table with many rows

Open rockyzhang24 opened this issue 4 years ago • 6 comments

I try to use a table as a "table of content" in a markdown file. It has more than 1000 lines. However, it gets quite slow, especially when the width of a column needs to be adjusted or a new column is inserted. Is there a way to boost its performance? Thank you.

rockyzhang24 avatar Mar 23 '21 14:03 rockyzhang24

@yanzhang0219 Thanks for letting me know, would have to investigate, likely needs some optimisations. I have personally never dealt with such long tables.

dhruvasagar avatar Mar 23 '21 16:03 dhruvasagar

Thank you very much. BTW, copying one row followed by pasting many times say 1000 is quite slow as well. When pasting, I can observe the pasting process, i.e., rows are added one by one, and they are not finished immediately.

Thanks.

rockyzhang24 avatar Mar 23 '21 17:03 rockyzhang24

That's likely vim itself, instead of pasting using some combination of Cmd +v or Ctrl + Shift + v if you just used p, or 1000p it shouldn't be as slow. @yanzhang0219

dhruvasagar avatar Mar 23 '21 18:03 dhruvasagar

Oh sorry. The pasting is fine. I remember incorrectly.

The issue I described above is related the insert column as well. If I have a table with 1000 row, then if I insert a column, after pressing <Leader>tic, I can observe the inserting process, i.e., rows are scanned one by one and I can see the table is scrolling till the end, instead of finishing immediately. I attached a short video below as a demo.

https://user-images.githubusercontent.com/11582667/112211047-ad341300-8bd8-11eb-91a4-a8ebee603b09.mov

What's more, with a 1000 row table, the cursor jumping is sluggish as well like gg or G.

Thank you.

rockyzhang24 avatar Mar 23 '21 20:03 rockyzhang24

@yanzhang0219 i'll investigate, although we're likely dealing with extremes here. There still should be scope for improvement, but is going to be limited by what vim itself can do. Things like sluggish on gg or G indicate it's vim that's slowing down because vim-table-mode doesn't do anything with regular movement. Certain filetypes syntax definitions can sometimes cause slowness. If it's not the syntax of the filetype itself, you may also try disabling vim-table-mode's table syntax, that could be the culprit too.

dhruvasagar avatar Mar 24 '21 05:03 dhruvasagar

Sure. I will try that. Thank you.

rockyzhang24 avatar Mar 24 '21 14:03 rockyzhang24

I'm experiencing sluggish performance with a table of only 40ish rows... Tried disabling the table syntax, but there is still definite slow-downs, for example when hitting in insert mode at the bottom of a table to insert a new row. I'm on neovim 0.8.

kflak avatar Oct 10 '22 06:10 kflak

@kflak Thanks for letting me know, I haven't tested much on such large tables. I will take a look, I am sure there are performance improvements that can be done. As a work around, I can recommend disable auto align feature and rely on manually aligning the table with :TableModeRealign instead, that way it should be easier to deal with large tables.

dhruvasagar avatar Oct 10 '22 08:10 dhruvasagar

Will see if I can give it a try later tonight! So far it seems like setting auto-align doesn't do anything, the table still realigns whenever I drop out of insert mode, even when setting it to 0?

kflak avatar Oct 10 '22 09:10 kflak

@kflak if you set g:table_mode_auto_align = 0 and restart vim, it should take effect.

dhruvasagar avatar Oct 10 '22 15:10 dhruvasagar

OK, think I figured it out! I was working on a table in vimwiki, and vimwiki has its very own way of dealing with tables... doh... So obviously things are going to crash head-on when I have two plugins fighting over who gets to do what at the same time.

kflak avatar Oct 11 '22 14:10 kflak

@kflak Interesting, kindly check by disabling vimwiki's table handling. Let me know if it's still an issue ?

dhruvasagar avatar Oct 11 '22 14:10 dhruvasagar

Seems to be nice and snappy when using it in a regular markdown file, when vimwiki is not in play.

kflak avatar Oct 11 '22 17:10 kflak