anna klein schrieb:
> Basically, I would like to insert sentence(s) at several positions in my
> document. The sentences are quite random. It can be inserting lines of
> sentences or just a character of \<NL> that is a new line. I have a list of
> sentences and the position where I should place the sentences. So, I guess
> the best thing to do is use 'goto' and then use 'normal i'.my sentences.
> For my function, I want the insertion of \<NL> should be preceded by an
> indent, so that if there is insertion later, I don't need to check whether
> there is a tab or not.
> However, for insertion of many sentences, I just want it copy blindly what
> the list says. If there is a indent at the front, then my document should
> have. If no indent, then my document should not have one.
> 
> Is there a way to turn on and off this auto indent?
> I tried to turn off autoindent and smartindent before doing my function, but
> no luck.
> 
> Anna

Autoindenting is no problem:
    :let @t = "Is there a way?"
    :exec "normal! i\<C-R>t"

This is like pressing "i" and typing the text from the register t.
    :h i_ctrl-r
    :h expr-string

And when typing text, the 'autoindent' option applies.
'smartindent' should be kept at the default (off).

Some issues:
- how to adjust leading and trailing white space in the resulting text
- use "i" or "o"?
- do embedded newlines in the sentence disturb the result?
- type of register content: characterwise or linewise

You can also insert the contents of a variable
    :let sentence = "This is a beautiful sentence."
    :exec "normal! i\<C-R>=sentence\r"

There is a script: Loremipsum, A dummy text generator
http://vim.sf.net/scripts/script.php?script_id=2289
Maybe it can also help you solve some of the issues.

-- 
Andy

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to