Switching off auto-indent within vim script...

37 views
Skip to first unread message

Sonny Chee

unread,
Oct 8, 2015, 5:56:20 PM10/8/15
to vim_use
Hey Guys,

When I want to insert text from my clipboard, I turn off auto-indenting with the following:

:setl noai nocin nosi inde=

That works great.

I'm working on a vimscript that inserts (prettily) formatted text into a buffer. I tried to execute the above before the inserts with the following:

execute "normal :setl noai nocin nosi inde="
execute 'normal! ' . l:start . 'Gg0o' . "\t" . join(l:cols, "\n\t, ")


But all of the text is auto-indented. Any help would be appreciated....

Erik Christiansen

unread,
Oct 9, 2015, 3:23:17 AM10/9/15
to vim_use
On 08.10.15 14:56, Sonny Chee wrote:
>
> But all of the text is auto-indented. Any help would be appreciated....

Have you tried "set paste", instead?

If pasting from the X Clipboard, there's also: "+p
(That was "*p in old Vim versions, IIRC.)

Erik

Ben Fritz

unread,
Oct 9, 2015, 10:26:43 AM10/9/15
to vim_use

I second the suggestion to use :set paste instead.

However, your script isn't working, because there is no "enter" command sent to execute the command-line. You COULD insert a "\<CR>" at the end of your first normal command to accomplish that.

But that's pointless. You're using the "execute" ex command to use the "normal" ex command that does a ":" to go into the command-line mode where you execute...ex commands.

Instead of all that, why not just use "setl noai nocin nosi inde=" directly?

Sonny

unread,
Oct 9, 2015, 1:48:34 PM10/9/15
to vim...@googlegroups.com
Thanks guys for the pointer to :set paste.  Also appreciate the help debugging the issue with my script Ben.


--
--
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/JPptXTuUuxI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Sonny.
----------------------------------------------------------------------------
Be true to your work, your word, and your friend. Henry David Thoreau.

Simon Ruderich

unread,
Oct 9, 2015, 5:29:30 PM10/9/15
to vim_use
On Fri, Oct 09, 2015 at 06:27:15PM +1100, Erik Christiansen wrote:
> (That was "*p in old Vim versions, IIRC.)

Are you sure? According to the Vim help, "* is the primary X
selection and "+ is the X clipboard.

Regards
Simon
--
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
signature.asc
Reply all
Reply to author
Forward
0 new messages