indent file from command line without blinking

18 views
Skip to first unread message

Peng Yu

unread,
Apr 13, 2020, 7:29:46 PM4/13/20
to vim_use
I use the following command to indent file in command line. But it blinks. Is there a way to let it not blink? Thanks.

vim -n -X -E -c 'normal gg=G' -c 'x' file.sh < /dev/tty

Christian Brabandt

unread,
Apr 14, 2020, 4:01:21 AM4/14/20
to vim_use

On Mo, 13 Apr 2020, Peng Yu wrote:

> I use the following command to indent file in command line. But it blinks. Is there a way to let it not blink? Thanks.
>
> vim -n -X -E -c 'normal gg=G' -c 'x' file.sh < /dev/tty

What blinks?


Best,
Christian
--
An Grundsätzen hält man nur fest, solange sie nicht auf die Probe
gestellt werden; geschieht das, so wirft man sie fort wie der Bauer
die Pantoffeln und läuft, wie einem die Beine nach der Natur gewachsen
sind.
-- Otto von Bismarck

Tim Chase

unread,
Apr 14, 2020, 8:32:43 AM4/14/20
to vim...@googlegroups.com
On 2020-04-14 10:01, Christian Brabandt wrote:
> On Mo, 13 Apr 2020, Peng Yu wrote:
>
> > I use the following command to indent file in command line. But
> > it blinks. Is there a way to let it not blink? Thanks.
> >
> > vim -n -X -E -c 'normal gg=G' -c 'x' file.sh < /dev/tty
>
> What blinks?

I think it refers to painting the vim GUI, possibly switching to the
alternate screen, then clearing the (possibly alternate screen), then
possibly restoring the (non-)alternate screen, creating a "flash"
effect when scripting vim.

-tim


Christian Brabandt

unread,
Apr 14, 2020, 9:18:09 AM4/14/20
to vim...@googlegroups.com
Since this depends on the terminal, you can either pretend using a dumb
terminal:

TERM=dumb vim -n -X -E -c 'normal gg=G' -c 'x' file.sh < /dev/tty

or alternatively use set the `t_ti` and `t_te` terminal options to
empty:

vim -n --cmd ':set t_ti= t_te=' -X -E -c 'normal gg=G' -c 'x' file.sh < /dev/tty


Best,
Christian
--
Du wirst in einer Onlinedatenbank alles finden, nur nicht das, was du suchst.

Peng Yu

unread,
Apr 14, 2020, 12:45:36 PM4/14/20
to vim...@googlegroups.com
>> I think it refers to painting the vim GUI, possibly switching to the
>> alternate screen, then clearing the (possibly alternate screen), then
>> possibly restoring the (non-)alternate screen, creating a "flash"
>> effect when scripting vim.
>
> Since this depends on the terminal, you can either pretend using a dumb
> terminal:
>
> TERM=dumb vim -n -X -E -c 'normal gg=G' -c 'x' file.sh < /dev/tty

$ TERM=dumb vim -n -X -E -c 'normal gg=G' -c x
/tmp/mktemp/tmp.qfqXJ1jHwd/file2.sh
3 lines indented
"/private/tmp/mktemp/tmp.qfqXJ1jHwd/file2.sh" 3L, 44C written

> or alternatively use set the `t_ti` and `t_te` terminal options to
> empty:
>
> vim -n --cmd ':set t_ti= t_te=' -X -E -c 'normal gg=G' -c 'x' file.sh <
> /dev/tty

$ vim -n --cmd ':set t_ti= t_te=' -X -E -c 'normal gg=G' -c x
/tmp/mktemp/tmp.OLOOB8goR1/file2.sh
3 lines indented
"/private/tmp/mktemp/tmp.OLOOB8goR1/file2.sh" 3L, 44C written

I still get something printed. How to turn it off? So `< /dev/tty` is
not needed anymore for both cases?

--
Regards,
Peng

Christian Brabandt

unread,
Apr 14, 2020, 12:48:53 PM4/14/20
to vim...@googlegroups.com

On Di, 14 Apr 2020, Peng Yu wrote:

> I still get something printed. How to turn it off? So `< /dev/tty` is
> not needed anymore for both cases?

Use the :silent modifier?

Best
Christian
--
Ich verabscheue, was Sie sagen: ich werde Ihr Recht, es zu sagen, bis
zum Tod verteidigen.
-- François Marie Voltaire

Peng Yu

unread,
Apr 14, 2020, 1:17:32 PM4/14/20
to vim...@googlegroups.com
Could you show the complete command? I can not get it work. Thanks.
> --
> --
> 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 a topic in the
> Google Groups "vim_use" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/vim_use/NPYJ4b66dms/unsubscribe.
> To unsubscribe from this group and all its topics, 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/20200414164845.GN25035%40256bit.org.
>


--
Regards,
Peng

Christian Brabandt

unread,
Apr 14, 2020, 1:51:26 PM4/14/20
to vim...@googlegroups.com

On Di, 14 Apr 2020, Peng Yu wrote:

> Could you show the complete command? I can not get it work. Thanks.

Seems not to be easily possible.

Best,
Christian
--
Wie man sein Kind nicht nennen sollte:
Bernhard Diener
Reply all
Reply to author
Forward
0 new messages