Questions tagged [text-generation]
Automatically generating text with Vim, using patterns like incrementing numbers, etc.
32
questions
1
vote
1
answer
136
views
How to generate random string with required length in Vim?
I am using this code for console log
nmap cll yiwocll<Esc>p
I wanted to add some random string inside this console log, assume 10 characters symbols length.
How to achieve this?
0
votes
1
answer
93
views
Shell script runs multiple times, I want it to run only once
I use vim pretty extensively for latex compiling. I've a function which automatically compiles the current tex file. I use pdflatex as a compiler, which creates a bunch of different files that it ...
0
votes
1
answer
53
views
Change text without interrupting abbreviations
I'd like to add a semicolon automatically in my current line. So I have this in my init.vim:
function Test()
if matchstr(getline(line('.')), ';') != ';' && strlen(getline(line('.'))) > ...
6
votes
3
answers
857
views
Create indented comment box vim
Background
I have a code file and I like to place comments inside my code. Sometimes, these comments are boxed:
defmodule BananasModule do
##############
# Public API #
##############
...
0
votes
1
answer
287
views
Increment the number at the end of variable
In my C code I am dealing with many variables of type
RxMsgType0
RxMsgType1
RxMsgType2
RxMsgType3
...
My Question: Is there a way in VIM by which I can create 4 more variables which follow the ...
1
vote
2
answers
723
views
VIM command to insert multiline text with argument
new VIM user. I'm trying to make creating python properties easier for my class definitions. What I would like for say I type
:pyp x
then VIM will autofill where my cursor is
@property
def x(self):...
1
vote
4
answers
877
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 (...
2
votes
1
answer
378
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
0
answers
87
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
2
answers
238
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
1
answer
32
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
1
answer
40
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
1
answer
314
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
3
answers
238
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
3
answers
373
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
1
answer
347
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 ...
4
votes
1
answer
2k
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 ...
6
votes
5
answers
7k
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, ...
7
votes
3
answers
5k
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
3
answers
978
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 ...
4
votes
1
answer
2k
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
0
answers
54
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
3
answers
563
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
5
answers
4k
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
2
answers
950
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"...
6
votes
2
answers
2k
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
3
answers
1k
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
0
answers
144
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 ...
31
votes
8
answers
11k
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?
27
votes
8
answers
13k
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
2
answers
58
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 ...
39
votes
5
answers
7k
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 ...