Quantcast

Having certain lines readonly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Having certain lines readonly

Tihomir Mitkov
Is it possible to have certain lines uneditable while keeping the rest of them editable?

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Having certain lines readonly

Ben Fritz
On Tuesday, January 3, 2017 at 1:15:48 AM UTC-6, Tihomir Mitkov wrote:
> Is it possible to have certain lines uneditable while keeping the rest of them editable?

No.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Having certain lines readonly

Tim Chase
In reply to this post by Tihomir Mitkov
On 2017-01-02 03:42, Tihomir Mitkov wrote:
> Is it possible to have certain lines uneditable while keeping the
> rest of them editable?

The closest I've heard of is the "narrow region" plugin

  https://github.com/chrisbra/NrrwRgn

-tim


--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Having certain lines readonly

Erik Christiansen
In reply to this post by Tihomir Mitkov
On 02.01.17 03:42, Tihomir Mitkov wrote:
> Is it possible to have certain lines uneditable while keeping the rest of them editable?

In *nix, almost anything is possible. You could either excise the
protected lines with e.g. Awk, then reinsert them after exit from Vim
to the wrapper script, or leave them for whatever user benefit exists,
then overwrite them on exit, to defeat edits.

The protection zone could be primitively defined by line numbers, by
recognisable intrinsic content, or by arbitrary added delimiters.

If it were necessary to enforce reciprocal protection, i.e. those with
permission to edit the primary protected text should not touch the other
text (even if only to avoid finger fumbles), then the two halves could
perhaps be kept as identically named files in two adjacent directories,
with differing group ownership and limited write permissions, merged
only for consumption, not for editing.

In that case, Vim could be invoked on both files, perhaps in two tabs,
with the correct one automatically being read-only, as enforced by the
*nix permissions of the files, and the *nix group membership of the users.

Erik

--
Emacs is a nice OS - but it lacks a good text editor.
That's why I am using Vim.                               - Anonymous

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Having certain lines readonly

Tihomir Mitkov
вторник, 10 януари 2017 г., 9:13:02 UTC+2, Erik Christiansen написа:

> On 02.01.17 03:42, Tihomir Mitkov wrote:
> > Is it possible to have certain lines uneditable while keeping the rest of them editable?
>
> In *nix, almost anything is possible. You could either excise the
> protected lines with e.g. Awk, then reinsert them after exit from Vim
> to the wrapper script, or leave them for whatever user benefit exists,
> then overwrite them on exit, to defeat edits.
>
> The protection zone could be primitively defined by line numbers, by
> recognisable intrinsic content, or by arbitrary added delimiters.
>
> If it were necessary to enforce reciprocal protection, i.e. those with
> permission to edit the primary protected text should not touch the other
> text (even if only to avoid finger fumbles), then the two halves could
> perhaps be kept as identically named files in two adjacent directories,
> with differing group ownership and limited write permissions, merged
> only for consumption, not for editing.
>
> In that case, Vim could be invoked on both files, perhaps in two tabs,
> with the correct one automatically being read-only, as enforced by the
> *nix permissions of the files, and the *nix group membership of the users.
>
> Erik
>
> --
> Emacs is a nice OS - but it lacks a good text editor.
> That's why I am using Vim.                               - Anonymous
Thank for your post. I figured out that I can simulate readonly lines by keeping metadata about lines and remapping all keys to a function which decides upon that  metadata whether to put the character in question.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Having certain lines readonly

lith
> Thank for your post. I figured out that I can simulate readonly lines by keeping metadata about lines and remapping all keys to a function which decides upon that  metadata whether to put the character in question.

An alternative approach would be to use the CursorMoved(I) events to toggle the readonly option depending on which line the cursor is located at.

E.g. the setsyntax plugin (http://www.vim.org/scripts/script.php?script_id=2076) can be used to achieve something like this based on the syntax group under the cursor.

Regards

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Having certain lines readonly

Tihomir Mitkov
неделя, 15 януари 2017 г., 16:10:42 UTC+2, lith написа:
> > Thank for your post. I figured out that I can simulate readonly lines by keeping metadata about lines and remapping all keys to a function which decides upon that  metadata whether to put the character in question.
>
> An alternative approach would be to use the CursorMoved(I) events to toggle the readonly option depending on which line the cursor is located at.
>
> E.g. the setsyntax plugin (http://www.vim.org/scripts/script.php?script_id=2076) can be used to achieve something like this based on the syntax group under the cursor.
>
> Regards

CursorMoved(I) would be much more robust. Thanks for your advice.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Having certain lines readonly

Ben Fritz
On Monday, January 16, 2017 at 12:06:05 PM UTC-6, Tihomir Mitkov wrote:

> неделя, 15 януари 2017 г., 16:10:42 UTC+2, lith написа:
> > > Thank for your post. I figured out that I can simulate readonly lines by keeping metadata about lines and remapping all keys to a function which decides upon that  metadata whether to put the character in question.
> >
> > An alternative approach would be to use the CursorMoved(I) events to toggle the readonly option depending on which line the cursor is located at.
> >
> > E.g. the setsyntax plugin (http://www.vim.org/scripts/script.php?script_id=2076) can be used to achieve something like this based on the syntax group under the cursor.
> >
> > Regards
>
> CursorMoved(I) would be much more robust. Thanks for your advice.
I think you're still going to have trouble with commands which can modify multiple lines. What will you do to handle global search-and-replace via ":%s/pat/rep/g"? Or multiple-line delete with either "10dd" or ":123,456d"? There are too many ways to modify lines to protect a specific range of lines from all edits, which is what I'd expect from a "read only lines" feature.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...