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: the [repeated-commands] tag

Filter by
Sorted by
Tagged with
-1
votes
1answer
32 views

Why are so many underscore lines in my file when to open it with vim?

Everytime i opened a file with vim,so many underscore lines in it such as below: How can remove all the underscore lines ? :colorsheme is desert. The highlight output: The terminal is LXTerminal. ...
0
votes
1answer
41 views

How to select non-uniform length strings from within multiple lines

Suppose I have this data: import { york1400 } from "./data/york1400"; import { york1430 } from "./data/york1430"; import { york1500 } from "./data/york1500"; import { ...
1
vote
0answers
21 views

How to see offscreen undo changes?

Imagine a text file with some words on the first line, one-thousand blank lines, and some text on the last line. this is a first line of text. <1000 blank lines> Last line of text. From the ...
2
votes
2answers
80 views

Keeping lines in vim with certain number of columns

I have a large file which have some corrupt lines like this 0.6 8 379699 730 0.999769 0.802075 0.912155 0.6 8 379699 731 0.999698 0.8181070.8 8 377999 0 0.674844 0.765493 0....
2
votes
2answers
244 views

Repeat complex actions over a number of lines (in Vim)

I am editing a LaTeX document and I wanted to figure out the most efficient way to convert itemize environment to tabular environment. Here is an example of what I want to accomplish: Change \begin{...
0
votes
2answers
23 views

search and replace block to a line

I would like to replace a multiline block to one line for example : if (... ){ //comment0 line1 line2 } some code if (... ){ //comment0 line1 line2 } ...
1
vote
1answer
115 views

MVim terminal, how to execute multiple commands

I am trying to use MacVim's :terminal to execute some commands, but for some reasons I fail to make even the simplest functions work. Here are some examples: :function TryF() : execute '...
1
vote
3answers
1k views

How to delete line endings in Vim?

Suppose I have several words on multiple lines: R T_std k_AB_IN k_AB_ac k_AB_co2 k_La Now I want them to have them all on one line, only seperated by one ...
0
votes
1answer
84 views

Multiline context errors

Sometimes I see multiline popup-base errors in screencasts like the one below: Would anyone point me with a term or something to google it, as my ideas don't work for some reason? Here's configs of ...
1
vote
2answers
35 views

How to replace everything between PORT= and )

I have a (copy of) oracle listener log, and would like to replace the portnumber in every line. These are always of the form (PORT=1234) with sometimes 4 and sometimes 5 numbers. So an exampleline, ...
1
vote
1answer
1k views

Yank multiple lines without using visual mode

I have the text: abcd abcd abcd abcd my cursor is in the first line, and I want to yank the first 2 lines. Usually I would do it by pressing Shift+v, selecting the second line by going down with j ...
7
votes
3answers
3k views

How can I add text to the end of words on each line?

I have a series of single-word codes on separate lines in a text file. I'd like to add a backquote ( ` ) to the beginning and end of each word. I know I can add a backquote to the beginning of each ...
1
vote
1answer
301 views

Deletion in multi-line edit mode

In Normal mode I use the following combination to edit multiple lines: Ctrl + v Select lines to edit Shift + i Edit line Esc However, this method only applies changes to the first line if character ...
0
votes
1answer
70 views

Discrete Visual mode

A feature that I love in VSCode is to be able to use my mouse to click at multiple points in the screen and type with multiple cursors. I am aware that in Vim you can do the same in visual mode, but ...
5
votes
3answers
699 views

How can I sort multiline blocks in vim?

The task I have in mind is I have grown files containing multiline definitions. Currently I'm working on a file containing acronyms for latex - many entries like this, but most much more complex: \...
2
votes
3answers
62 views

How to do multiline non-rectangular deletion?

Here is a problem I am able to solve in Sublime in seconds but has me stumped in Vim: Given text like this: bob@bobshop.com Bob Potato peter@petershop.co.uk Peter Carrot thomas.cucumber@thomasstore....
2
votes
1answer
103 views

Break logical lines

I'm looking for a way to make a line be only logically broken at the end of the available space. Here's an example: let's suppose I have a really long line (i.e. a string without any \n in it), and to ...
2
votes
0answers
45 views

Remove 'jumps' when moving to last and first line in Vim [duplicate]

I have the display option set to lastline so that the last line is shown even if all it doesn't fit on the window. When moving down visual lines with gj to the last line that is only partially visible,...
6
votes
2answers
845 views

Paste append multiple lines

I search a way to paste/merge 2 block of text apple pear banana tomato beans potato like this apple tomato pear beans banana potato The lines have different length but same number of lines of ...
1
vote
1answer
145 views

Search/replace multiple lines with confirmation

I'm trying to write a substitution command that would search for a line that doesn't end with a space character and others (see regex) and isn't followed by an empty line. The line length may vary ...
2
votes
1answer
2k views

How to copy long line from terminal buffer as it is without adding new lines?

I wanted to copy a public key from one machine to the other. I opened up vim and had two terminal buffers - one for each machine. In the terminal in which I had the first machine I went into normal ...
4
votes
1answer
99 views

Shuffle multiline folds

Suppose I have a bunch of folds for more than one line each. How to make shuffle them as folds not lines? In case of lines it can be done by external shuf or any other command (see https://...
0
votes
2answers
143 views

How can I delete lines fit a pattern to a register or a new file?

I can use the powerful :g command to delete lines that contain a certain pattern like this: :g/^\va pattern/d I thought I should paste the deleted content to a new place but I cannot find all ...
1
vote
1answer
94 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 ...
5
votes
3answers
5k 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
263 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
2answers
524 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
1k 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
194 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
216 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
237 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 ...
3
votes
1answer
443 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 \ |...
2
votes
1answer
741 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
2k 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 ...
2
votes
2answers
241 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 ...
8
votes
2answers
352 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 ...
9
votes
1answer
2k 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> ...
4
votes
1answer
425 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
75 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 ...
5
votes
1answer
736 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
106 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/...
9
votes
2answers
483 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....
5
votes
2answers
7k 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....
1
vote
1answer
1k 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. +-------+ | | | | ...
4
votes
1answer
921 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 ...
2
votes
1answer
2k 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\...
4
votes
1answer
201 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 -...
10
votes
3answers
2k 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 ...
7
votes
3answers
8k 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
422 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\...