Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
3 votes
2 answers
148 views

How can I add a specific range of numbers into to each line at a particular location?

For example, we have: 1 this is line. please go to file example.txt for more information. 2 this is line. please go to file demo.txt for more information. 3 this is line. please go to file ...
user avatar
  • 33
-1 votes
1 answer
37 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. ...
user avatar
  • 820
0 votes
1 answer
44 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 { ...
user avatar
  • 197
1 vote
0 answers
22 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 ...
user avatar
2 votes
2 answers
115 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....
user avatar
  • 23
2 votes
2 answers
735 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{...
user avatar
  • 133
0 votes
2 answers
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 } ...
user avatar
1 vote
1 answer
194 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 '...
user avatar
  • 143
2 votes
3 answers
3k 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 ...
user avatar
  • 123
0 votes
1 answer
117 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 ...
user avatar
  • 155
1 vote
2 answers
50 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, ...
user avatar
  • 11
1 vote
1 answer
2k 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 ...
user avatar
  • 21
8 votes
3 answers
5k 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 ...
user avatar
  • 205
2 votes
1 answer
695 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 ...
user avatar
0 votes
1 answer
79 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 ...
user avatar
5 votes
3 answers
866 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: \...
user avatar
  • 259
2 votes
3 answers
89 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....
user avatar
  • 197
2 votes
1 answer
127 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 ...
user avatar
  • 187
2 votes
0 answers
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,...
user avatar
8 votes
2 answers
1k 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 ...
user avatar
1 vote
1 answer
176 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 ...
user avatar
  • 239
3 votes
1 answer
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 ...
user avatar
  • 103
4 votes
1 answer
112 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://...
user avatar
  • 223
1 vote
2 answers
202 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 ...
user avatar
1 vote
1 answer
106 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 ...
user avatar
5 votes
3 answers
6k 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 ...
user avatar
  • 900
1 vote
2 answers
286 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 ...
user avatar
  • 113
2 votes
2 answers
582 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 ...
user avatar
  • 123
2 votes
2 answers
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 ...
user avatar
0 votes
1 answer
257 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 ...
user avatar
  • 121
0 votes
1 answer
269 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 ...
user avatar
2 votes
2 answers
292 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 ...
user avatar
  • 16.5k
3 votes
1 answer
463 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 \ |...
user avatar
  • 195
2 votes
1 answer
850 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 ...
user avatar
  • 123
2 votes
1 answer
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 ...
user avatar
  • 123
2 votes
2 answers
263 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 ...
user avatar
8 votes
2 answers
374 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 ...
user avatar
  • 141
9 votes
1 answer
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> ...
user avatar
  • 1,247
4 votes
1 answer
542 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 - ...
user avatar
  • 275
2 votes
1 answer
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 ...
user avatar
  • 159
5 votes
1 answer
774 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 ...
user avatar
  • 16.5k
4 votes
2 answers
111 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/...
user avatar
  • 16.5k
9 votes
2 answers
501 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....
user avatar
5 votes
2 answers
8k 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....
user avatar
  • 195
1 vote
1 answer
2k 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. +-------+ | | | | ...
user avatar
  • 3,012
4 votes
1 answer
988 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 ...
user avatar
  • 3,012
2 votes
1 answer
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\...
user avatar
  • 1,301
4 votes
1 answer
209 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 -...
user avatar
  • 143
11 votes
3 answers
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 ...
user avatar
7 votes
3 answers
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 ...
user avatar
  • 16.5k