【求助】打开CSS文件巨卡

最近在编辑一些CSS文件。有些CSS文件的单行非常长,会导致emacs打开和操作都非常卡。有没有啥办法能优化呢?这个单行还不能通过软硬回车来修改,现在只好用其他编辑器先用着。 emacs 27;感觉应该也没有开启什么特别的插件,试了原先建议的把company-css关掉,也没有啥效果。我觉得应该还是单行太长导致的。不知道该咋办了。

谢谢;

Emacs超长行性能就是辣鸡,你的长行有多长?

CSS 为啥会有长行呢

可能整个文件就1行

有些原始的CSS文件,还真是整个文件就一行。。。。。

font-lock-mode关掉就会有很大改善了。

Emacs27 自带了so-long-mode,也可以自动地解决这种问题

1 个赞

先把文件后缀改成txt试试

1 个赞

用一个800多k只有一行的css文件测试了一下,windows emacs27自带的css-mode,开启company,flycheck,hs-minor-mode,自动换行,当前行高亮;光标一直往下移不知道为什么行号就不会显示了,显示成??,列号正常显示,光标一直移到当前行2万多列都不卡,光标移到3万多列以后emacs才会开始卡。

所以只要光标不一直往下移到3万多列就没问题,不会卡,如果需要一直往下拉可以先执行format-all-mode格式化整个buffer,没有超级长行就没问题了

用一个129k的有超长行(13万列)的js文件试了下,emacs-tree-sitter 也很卡

emacs-tree-sitter这个是什么东西,有什么作用?不太明白,这个就是王垠在有篇博客里面讲到的终极解决方案,结构化编辑器吗?

1 个赞

Developer tools that support multiple programming languages generally have very limited, regex-based code-analysis capabilities. Tree-sitter is a new parsing system that aims to change this paradigm. It provides a uniform C API for parsing an ever-growing set of languages. It features high-performance incremental parsing and robust error recovery, which allow it to be used to parse code in real-time in a text editor. There are bindings for using Tree-sitter from Node.js, Haskell, Ruby and Rust.

https://www.reddit.com/r/emacs/comments/chnxzm/dynamic_module_binding_for_treesitter_an/

https://www.reddit.com/r/emacs/comments/ejv389/emacsdevel_using_incremental_parsing_in_emacs/

youtube那个视频讲解的比较清楚

1 个赞