Questions tagged [text-generation]

Automatically generating text with Vim, using patterns like incrementing numbers, etc.

Filter by
Sorted by
Tagged with
1
vote
4answers
156 views

In Vim ex mode how to re-use a string from the default buffer in the command

I'm trying to modify this file, by extracting the very first line in the file and prepend it to each of the consecutive lines until end of the file black widow card Friday berry I used ex command (...
0
votes
1answer
46 views

Copy text from one buffer to another using Vimscript

I need to process text line by line in one buffer and append the processed text to another buffer in Vimscript. I can do this by using buffer switching ex commands, but I suspect it will cause ...
1
vote
0answers
69 views

Trim/clear new line character from batch script at Windows7 with gvim

I want to put timestamp using Leaderts (\ts) I am using the following script timestamp.bat(Windows 7): @echo off cls echo|set /p=%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2% and the ...
1
vote
1answer
89 views

How to add specific string if it is not exists in current file?

I want to add this string "declare(strict_types=1);" after <?php when I save or open a file. <?php declare(strict_types=1); If the file already contains declare(strict_types=1); don't do ...
1
vote
1answer
22 views

Fields in templates without resorting to commented-out lists (aka are drop-down options possible?)

I do a lot of work in plain TeX and XeTeX, editing the documents in vim, and have a variety of templates which I use to make the process more efficient. As you might expect, these use quite a lot of ...
1
vote
1answer
38 views

Plugin to ignore quote when it's already there?

Please forgive me as I'm sure this has been asked before, but my Google fu has really failed me here as I'm not sure what this feature is called. Given text like this: "Hello ~" with the cursor where ...
1
vote
1answer
162 views

How to copy each line 19 times, incrementing two different numbers by 180?

I had asked a similar question previously (How to copy each line 11 times, incrementing the last "1" in each line from 2-12). I wasn't sure if I should ask this follow-up question in that ...
2
votes
3answers
185 views

How to write 1 or 0(binary string) randomly in a file using vim?

I want a file that contain only 1 and 0 for my java networking program. Writing a big file containing only 1 and 0 is boring. So, if vim do this, it is better. I don't know that it is whether ...
0
votes
3answers
127 views

Add line at the end of text

I have 5000 text files in a folder with different names. I just need to add one more line to the end in all files. Example: HELLO HELLO HELLO HELLO I need make it HELLO HELLO HELLO HELLO abc ...
2
votes
1answer
145 views

How to automate populating Python's class constructor?

I've done some searching with various keywords, but unsuccessfully. Sorry for my English, I'm not a native speaker. I'm new to VIM and to Python, and I'm learning both on the go as much as I can, but ...
2
votes
1answer
556 views

Insert character until column number

I'd like to define a vim command with the following functionality. 60<F7>= insert = at the end of the line until the line become 60 characters long. <F7>* insert * until the line becomes ...
5
votes
5answers
2k views

How to generate closing tags for HTML?

I want to do the following: When I insert an HTML tag (which is a sequence of text that starts with <tagname tag_attributes and ends with >), as soon as I press > to insert the > character, ...
4
votes
2answers
2k views

Can I write Japanese (SKK) text in Vim?

I need to be break it to you guys, I use emacs. But just for one little thing. Recently I've been working with a good deal of Japanese people (the company is Japanese) and I got some idea of the ...
11
votes
3answers
566 views

How to insert repetitive text with minor difference in vim?

I want to insert text like this: similar text wordA similar text ... similar text wordB similar text ... similar text wordC similar text ... I know I can paste the text many times then use the ...
2
votes
1answer
398 views

CTRL-A with visual mode not working

According to the Vim help, using g CTRL-A with visual mode should change several lines in A to that in B: A: 1. 1. 1. 1. B: 1. 2. 3. 4. In my Vim, the CTRL-A is working in ...
2
votes
0answers
44 views

Why does append(…, readfile()) add a zero when run using Ctrl-R?

While looking for ways to solve How can I create a /* comments section with /// like in XCode?, I cam across this puzzling behaviour. Say I have foo.txt containing: /*! * @author Robbie Yi JIANG, 29-...
8
votes
3answers
310 views

How can I create a /* comments section with /// like in XCode?

In XCode, there is an add-on called vvdocument, which can detect three / hits, and transfer /// into: /*! * @author Robbie Yi JIANG, 29-Jan-2016 14:01:45 * * */ How can I do this in Vim.
9
votes
5answers
2k views

How to copy each line 11 times, incrementing the last “1” in each line from 2-12

I have a number of lines in a file, and I would like to copy each line 11 times (turning each line into 12 lines), and increment the last "1" in each line so that the 12 lines have "1" through "12", ...
4
votes
2answers
532 views

How to add a uid to html nodes?

I have a giant html file which is a mess (not my fault). I want to add to some nodes (about 400) a unique id. They all have are of the same class, so I can add the id like this :% s/class="some-class"...
5
votes
2answers
881 views

How do I automatically add a character at end of line?

I am very new to vim and would like to know if I could have a script in my vimrc file that automatically adds a ; to the end of every line. The only exceptions is if the line has the strings for(, ...
3
votes
3answers
448 views

Command to create \begin{} \end{} environment in LaTeX

How can I make a command that allows me to insert LaTeX environments in the current text? The idea is to press Ctrl+E or type :texenv and then enter the environment name in the bottom line, e.g. :...
3
votes
0answers
100 views

How to convert lines to numbered list? [duplicate]

I've few lines (or paragraph if easier - {, }) which I would like to convert to numbered/ordered list, in example: Item one Item two Item three into: 1. Item one 2. Item two 3. Item three I would ...
23
votes
5answers
4k views

How to generate random numbers?

I would like to generate one or few random numbers separated by new line. How this can be done?
19
votes
8answers
3k views

How to add permanent line numbers to a file?

I have a text file like this (using gVim on Windows) foo bar baz quux corge grault garply waldo fred plugh [...150 more lines...] xyzzy thud I want to add a number to each line in the file. Not ...
1
vote
2answers
51 views

Created a formatted list of percentages efficiently

Let's say we wanted to produce the following text in a very "vim" way: Row 1 { 33.33%; } Row 2 { 66.66%; } Row 3 { 100%; } This isn't too complicated, but I think of it as a standin for ...
36
votes
5answers
2k views

How can I generate a list of sequential numbers, one per line?

Starting from a blank slate, how can I obtain a document that contains 1 2 3 4 5 6 7 8 9 10 … 100 To be clear, I don't want these numbers displayed in the margin; I want them inserted into the ...