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
0 votes
1 answer
74 views

Any .vimrc hacks to make vim automatically start a new line when you exceed line length?

Normally, when you type text (this is just annoyance when you are taking notes) in vim, and you exceed the line length of the program, it keeps the line going but the line number isn't present: 100 ...
user avatar
0 votes
1 answer
19 views

Manually indenting lines with tabs

Lines can be indented with tab characters. And it is quite obvious the there are better ways to do that than manually adding a tab character to the beginning of each line. But how to discover these ...
Volker Siegel's user avatar
2 votes
2 answers
171 views

Replace characters in relative linespan

I know that I can replace characters in a linespan via something to the effect of :300,305s/foo/bar/g But when I'm deep in the code, and I know that I just want to replace in the next five lines, I'm ...
Yehuda's user avatar
  • 275
0 votes
1 answer
101 views

How to join multiple lines which doesn't include space at the end

I'm working on a subtitle document (.srt) which has thousand of lines. But this issue is not about the subtitle documents, I going to export as plain text to read after. To see the dialogs line by ...
Pascowl's user avatar
3 votes
2 answers
711 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 ...
data 's user avatar
  • 33
0 votes
1 answer
196 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. ...
showkey's user avatar
  • 1,086
0 votes
1 answer
70 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 { ...
Ben Frain's user avatar
  • 217
1 vote
0 answers
24 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 ...
Jordan Mandel's user avatar
2 votes
2 answers
299 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....
Thomas's user avatar
  • 23
2 votes
2 answers
3k 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{...
Vladimir's user avatar
  • 135
0 votes
2 answers
27 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 } ...
Dor marcus's user avatar
1 vote
1 answer
324 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 '...
Kore-N's user avatar
  • 143
5 votes
3 answers
14k 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 ...
winkmal's user avatar
  • 165
0 votes
1 answer
265 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 ...
imbolc's user avatar
  • 155
1 vote
2 answers
73 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, ...
Paul A's user avatar
  • 11
1 vote
1 answer
3k 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 ...
m7bits's user avatar
  • 21
9 votes
3 answers
7k 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 ...
Yehuda's user avatar
  • 275
5 votes
1 answer
3k 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 ...
Luís de Sousa's user avatar
0 votes
1 answer
89 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 ...
justahuman's user avatar
6 votes
3 answers
2k 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: \...
bdecaf's user avatar
  • 279
2 votes
3 answers
136 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: [email protected] Bob Potato [email protected] Peter Carrot thomas.cucumber@thomasstore....
Ben Frain's user avatar
  • 217
2 votes
1 answer
183 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 ...
LuxGiammi's user avatar
  • 187
2 votes
0 answers
46 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,...
E7_82_8E's user avatar
8 votes
2 answers
2k 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 ...
OlivierF's user avatar
1 vote
1 answer
339 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 ...
ka3ak's user avatar
  • 261
4 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 ...
ivan's user avatar
  • 243
4 votes
1 answer
141 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://...
petRUShka's user avatar
  • 243
2 votes
2 answers
309 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 ...
Lerner Zhang's user avatar
1 vote
1 answer
127 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 ...
user1717828's user avatar
8 votes
3 answers
8k 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 ...
Fisher's user avatar
  • 1,032
1 vote
2 answers
361 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 ...
farnsy's user avatar
  • 113
2 votes
2 answers
720 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 ...
user8162's user avatar
  • 123
4 votes
2 answers
2k 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 ...
john c. j.'s user avatar
1 vote
1 answer
448 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 ...
juaninf's user avatar
  • 153
0 votes
1 answer
701 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 ...
user3.1415927's user avatar
2 votes
2 answers
389 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 ...
kenorb's user avatar
  • 18k
3 votes
1 answer
513 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 \ |...
nalzok's user avatar
  • 195
2 votes
1 answer
1k 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 ...
JHiant's 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 ...
krizzo's user avatar
  • 123
2 votes
2 answers
301 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 ...
Evan Carroll's user avatar
  • 1,146
8 votes
2 answers
404 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 ...
Jonathan's user avatar
  • 141
10 votes
2 answers
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> ...
Luke Davis's user avatar
  • 1,377
4 votes
1 answer
683 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 - ...
Samuel's user avatar
  • 275
2 votes
1 answer
79 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 ...
xis's user avatar
  • 159
5 votes
1 answer
897 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 ...
kenorb's user avatar
  • 18k
4 votes
2 answers
117 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/...
kenorb's user avatar
  • 18k
9 votes
2 answers
571 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....
Henricus V.'s user avatar
6 votes
2 answers
9k 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....
mfakhrusy's user avatar
  • 205
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. +-------+ | | | | ...
SibiCoder's user avatar
  • 3,282
4 votes
1 answer
1k 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 ...
SibiCoder's user avatar
  • 3,282