dyng / ctrlsf.vim

A text searching plugin mimics Ctrl-Shift-F on Sublime Text 2
1.59k stars 86 forks source link

Make filename not editable #327

Closed otavioschwanck closed 2 years ago

otavioschwanck commented 2 years ago

Would be nice to make the filenames not editable. Sometimes :%s/old/new/gr changes the filename and breaks ctrlsf on save.

A good suggestion for the future is that when filename is changed, also, renames the file

dyng commented 2 years ago

I don't know how vim can make some specific lines uneditable (only read-only mode for the whole file). Thanks for your suggestion, if you get some ideas to approach this, please let me know.

otavioschwanck commented 2 years ago

I don't know how vim can make some specific lines uneditable (only read-only mode for the whole file). Thanks for your suggestion, if you get some ideas to approach this, please let me know.

@dyng

You can export a list of the lines that are readonly at first. like: [22,44,66].

You also export in the background a copy of the ctrlsf file.

Add a autocmd, every time the file is changed, verify those lines, if they are different then the copy, revert only those line to the original values.