Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [multiple-lines]

Questions where working on more than one line is a relevant aspect. In most cases that means repeating the same command(s) over several lines. – Related: [tag:repeated-commands]

0
votes
1answer
18 views

How can I stagger text in vim?

Given the following text: 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 How can each line be shifted left/right an amount related to their line number? Desired outputs: 1 2 3 4 5 1 2 3 4 5 ...
0
votes
2answers
36 views

Visual Block Mode: How to insert text to multiple lines after line ending?

Below example, first line is shorter than the other lines. I want to insert \ to all lines at the highlighted place. If I press CtrlC, jjj(select all lines) , Shifti, \, only first line changed. How ...
1
vote
2answers
26 views

Multiline regular expression excluding characters

I am designing a syntax rule (for R code) that highlights if I do not start a function with a curly all by itself. For example, A <- function(x, y){ would be match but I do ...
2
votes
1answer
76 views

How to autoformat a multi-line string

I want to format a multiline string according to a textwidth of 32. group: - normal: scalar - multiline: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor ...
1
vote
2answers
68 views

Keep the full visual selection after indenting in easy mode vim

What is the best way to indent multiple lines in insert mode? Here is what I have currently: vmap <Tab> > vmap <S-Tab> < The problem is that it doesn't properly handle selection ...
0
votes
1answer
56 views

Replace capitalized letters in matching lines

I have multiple lines with the key "booktitle": booktitle={Advances in Cryptology - CRYPTO' 89 Proceedings}, volume={435}, series={Lecture Notes in Computer Science}, I would like to replace ...
0
votes
1answer
40 views

How can I soft-wrap a word to a new line?

Using textwidth (tw=74) a word will be moved to the next line (with an indent usually) with a newline character at the end of the line avoiding over-length. This is a hard wrap, and resizing the ...
2
votes
2answers
82 views

How to remove lines which have lower numbers than before, and keep only the sequential?

In order to parse certain log file and make a plot of sequential numbers, I need to filter out the lines with numbers which appearing lower than in the previous lines. For example, given the list of ...
1
vote
1answer
82 views

endif treated as part of command in autocmd

Here is my code: autocmd BufWritePost *.c,*.cpp,*.h \ let dir=expand('<amatch>:p:h') \ | if filereadable(dir.'/Makefile') || filereadable(dir.'/makefile') \ | Make > /dev/null \ |...
3
votes
1answer
122 views

How do I remove newlines inside arbitrary xml tags matching a pattern?

I'm working with large xml files that have tags, and some are spread across multiple lines, and some are on a single line. I'd like them to all be on a single line. There are other tags in the files ...
1
vote
1answer
588 views

Repeating multi-lines and increment numbers in specific sections?

I want to create a file that has X number of entries where each entry has incremental numbers for Y. I tried recording a macro that would copy the 3 lines then edit the value but it ended up editing ...
3
votes
2answers
60 views

How do I quote tabulated columns?

Currently, I'm using Vim Surround to make quoting easy on Multiple whole-lines Visual blocks Individual words However, it doesn't seem to make the job easy on columns, for example. Take this ...
6
votes
2answers
157 views

How to store all occurrences of a multiline search in a register?

I'm not sure if I've failed at searching for the answer to this, but now I've worked it out I wanted to document it here. The problem is searching for a multiline pattern, and storing all such ...
7
votes
1answer
613 views

Visual scrolling/visual <C-e> and <C-y> across wrapped lines?

This has been asked on stackoverflow before, but it seems it still has no solution. Perhaps that has changed with Vim 8.0. I'd like to be able to scroll (i.e. scroll-wheel, or <C-y>/<C-e> ...
5
votes
1answer
95 views

multi-line insert after indentation whitespace

if I have a list of indented text test test test test test test test test test test test test test test and I wanted to convert it to a markdown list - test test - ...
2
votes
1answer
57 views

How to do restrict keyword inside special lines?

I am trying to write a VIM highlight file for Gaussian 09 inputs. One example of "control" line is shown below: # P TPSSTPSS 6-31G* DENSITYFIT OPT(VERYTIGHT) INT(ULTRAFINE) FREQ(NORAMAN) TITLE ...
4
votes
1answer
495 views

How to write each line into separate file?

I'd like to write content of the file into separate files each for each line. For example: Lorem ipsum dolor sit amet consectetur adipiscing elit I'd like to write 1st line into line1.txt, 2nd ...
4
votes
2answers
90 views

How to change text in other line when the pattern is found?

I've got this 4-line content: foo baa baz quz and I'd like to replace baa to bar only when quz is found. I've tried these commands (which highlights baa correctly, but says it's not found): :/quz/...
6
votes
2answers
332 views

Sort every few lines

I want to sort the following based on their keys case IndexError: PyErr_SetString(PyExc_IndexError, exc.str.c_str()); break; case ValueError: PyErr_SetString(PyExc_ValueError, exc.str....
2
votes
2answers
1k views

delete entire line after first whitespace on every line

I have a file (around 1.6 million lines) which formatted like this: -0.00697468 0 -1.95966e-49 101325 -3.06381 -0.00697468 0 -1.95966e-49 101325 -3.06381 -0.00697468 0 -1.95966e-49 101325 -3....
0
votes
1answer
488 views

How to paste a text block in visual block mode?

I want to paste text which spans across multiple lines and is rectangular. For example, a rectangular box representing a device topology diagram. +-------+ | | | | ...
3
votes
1answer
315 views

How to create multi-line abbreviations

I want to create an abbreviation for multiple lines. For example, when I type Doc, it has to print a four line text like ############### # function : # returns : # ############## When I tried to do ...
3
votes
1answer
869 views

How to copy multiple lines and paste at the end of a file

Suppose I have a file: class X(arg): \t#blabbla \tdef fun1(arg): \t\tsome code \n \tdef fun2(arg): \t\tsome code \n class A(arg): \t#blabbla \tdef fun0(arg): \t\tsome code \n \tdef fun3(arg): \t\...
1
vote
0answers
115 views

search within a paragraph, not across paragraphs [closed]

I need a macro/function/something, so that when a user presses F3 in vim, I need to find all the paragraphs (inside a utf-8 buffer), which contain three simple patterns (lets say for starters just ...
4
votes
1answer
115 views

Yanking lines from a multiple selection

I’m using the multiselect plugin. I have selected multiple contiguous blocks of code and want to yank all of them into one register. For example, from -- selected A -- —— unselected —— -- selected B -...
7
votes
3answers
580 views

How to delete till the end of the previous line?

An example (The ^ is the cursor position): Before: a bc def ghi j k l mn o p q rs ^ After: a bc def ghimn o p q rs ^ or at least: a bc def ghimn o p q rs ^ I know I ...
6
votes
3answers
4k views

How to delete a multi-line match?

For testing purposes I've opened the following file: vim http://example.com/ And I'm using the following command to delete a highlighted multi-line pattern: :/<body\_.\{-}body>/d which ...
2
votes
1answer
154 views

How to print a multi-line match?

I've a file where I would like to extract a multiline pattern in non-greedy way (similar to this scenario) by using ex editor. This example works fine: $ ex +'/aa/,/cc/p' -scq! <(echo -e "start\...
4
votes
2answers
190 views

How do I remove lines where its content already occured in the previous line?

For example I've the following text: This is my first line, but longer. This is my first line This is my second line, but longer. This is my second line This is my third line, but longer. This is my ...
2
votes
1answer
698 views

How to replace two-line match with its first backreference pattern?

Given the following example: aa aa bb bb cc dd I'm trying to replace two-line match (bb\nbb) with its first matching line (bb). What works: these two-lines can be matched by: /bb\_.\{-}bb (as per: ...