Tuesday, December 4, 2018

Re: I need to fool vim to think buffer starts at column n

On Di, 04 Dez 2018, Magnus Woldrich wrote:

> Gary, Tim,
>
> Thank you for your suggestions. The %>8c trick works, and I also found another way:
>
> :%s;\v\./\zs;;
>
> However:
>
> Since I don't want to type this every time, I made a cnoremap like so:
>
> cnoremap %s %s/\v\.\/\zs
>
> Which works, but what about all other operations that you can do on a buffer?
> cnoremapping 'g' for example isn't great, and I'd like to perform any
> arbitary function on the content in the buffer.
>
> The most ideal solution would be to have vim completely ignore the first
> columns, no matter what I do in the buffer.
>
> I'm not sure what direction I should go at this point.
>
> Check this short svg animation to see what I'm doing:
> http://japh.se/vidir_col.svg
>
> And this is the project itself: https://github.com/trapd00r/vidir

Sounded similar although I thought this was originally from Joey Hess.

I suppose, it's not really "ignore the first couple of characters", as
they may matter if you order the lines differently, isn't it? Else your
perl script could simply leave out putting those numbers into the buffer
in the first place and just add them after the file has been written
when you actually need them.

I don't think there are good alternatives. You can conceal the first
couple of characters, but that won't help against users changing those
unexpectedly.

I have written the NrrwRgn plugin, that might be an alternative. It can
open a selected region inside another window and on ':w' will write the
changes back into the original buffer. That won't help against ordering
the lines differently.

Best,
Christian
--
Letzte Worte des Briefbombenlegers:
"Wie war noch mal die Faxnummer?"

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: