unchangeable lines

55 views
Skip to first unread message

Vladimir Stenbock

unread,
Dec 26, 2019, 4:04:05 PM12/26/19
to vim...@googlegroups.com
Is it possible to mark some lines as unchangeable ?

Christian Brabandt

unread,
Dec 27, 2019, 2:58:51 AM12/27/19
to vim...@googlegroups.com

On Fr, 27 Dez 2019, Vladimir Stenbock wrote:

> Is it possible to mark some lines as unchangeable ?

This is not possible. A custom handmade plugin might work around this by
saving/restoring of lines, but in the core, Vim does not support this.

Best,
Christian
--
Eine Erfolgsformel kann ich dir nicht geben; aber ich kann dir sagen,
was zum Mißerfolg führt: Der Versuch, jedem gerecht zu werden.
-- Herbert Swope

Efraim Yawitz

unread,
Dec 29, 2019, 10:44:12 AM12/29/19
to vim_use
I wonder if this could be easily hacked into the code of vim by creating a new syntax group called Unchangeable or something and adding code to make it uneditable.

Maybe for now, create a syntax group and highlight it in a way that it reminds you not to change that text.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20191227075846.GN9787%40256bit.org.

Salman Halim

unread,
Dec 29, 2019, 10:59:14 AM12/29/19
to Vim Users
Might be useful. I currently use something such as the InlineEdit plugin to extract the lines I want to modify. (This also helps in big files where syntax highlighting is slow.)

How would this be persisted? If it adds markers within the same file, the file won't be compatible with other editors. Maybe a second file would be saved alongside the main file, but with a different extension to indicate that it contains metadata. (Abc.txt and ABC.txt.vimmetadata)

For a Vim-script solution, you'd probably have to remap every single command that can change text (i, a, c, d, r, their upper-case variants, etc.) that would have to check to see whether the range of lines affected contains any of the fixed lines and abort if so. 

--

Salman

Richard Mitchell

unread,
Dec 29, 2019, 11:21:22 AM12/29/19
to vim_use
This probably isn't what the original poster had in mind, but this made me think what if vim could use a template file that acted as a mask?

Anywhere characters (X for example) existed in the mask file, those positions would not be changeable in the 'edit' file.

If the movement commands skipped over the masked positions, you'd have a really handy tool for editing forms.

I don't know to who this would appeal, can't imagine there are a lot of people jonesing over a modal editor for forms instead of an html form and mouse.

To unsubscribe from this group and stop receiving emails from it, send an email to vim...@googlegroups.com.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim...@googlegroups.com.

Erik Christiansen

unread,
Jan 2, 2020, 1:46:02 AM1/2/20
to vim_use
On 29.12.19 17:43, Efraim Yawitz wrote:
> I wonder if this could be easily hacked into the code of vim by creating a
> new syntax group called Unchangeable or something and adding code to make
> it uneditable.

Or more easily in the folding code? That already treats an arbitrary
number of lines as a single unit when a fold is closed. To make a fold
immutable, its fold status would admittedly need to be checked by all
edit operations - when the fold is open - a condition when it is hardly
distinguishable from any other text.

If done there, the immutable text would inherently still be able to be
moved, like any other closed fold, without needing to toggle the
immutability tag on the fold, I figure.

The various existing foldmethods would seem well suited to delimiting
protected text. But how to add the protecting metadata in anything other
than an easily circumvented way is difficult to imagine.

Erik
Reply all
Reply to author
Forward
0 new messages