New answers tagged

3

If the file only contains a header line and (starting with line 2) data lines, you can use the \= special expression in the replacement text. This allows you to calculate the actual replacement text with an expression consisting of a mix of strings and numeric calculations: :2,$s!$!\=',' . ((line('.') - 2) / 10 + 1) . ',' . ((line('.') - 2) % 10 + 1)! This ...


3

Well, that turned out more complicated than expected: :2,$s:$:\=','.(((line('.')-2)%100)/10+1).','.(((line('.')-2)%10)+1) Probably would be easier with macros. You didn’t specify whether you want the third column to also reset when it gets to ten. I presumed you do. It doesn’t make any difference on your sample. I’m on my phone, so can’t post a full ...


2

Several things here, some answers, some tricks (?) visual mode, Escape, :* is exactly equivalent to visual mode, : (notice the :'<,'> markers got inserted; this is a :help [range] for visual mode, which is what :* is equivalent to). I just find typing one character (:) faster :) since most commands (like :substitute) take a range, if you learn how to ...


2

One option that I find quite flexible and intuitive is to use the :normal command with a range, in order to repeat a sequence of Normal mode commands on multiple lines of text. In this particular case, you can use that sequence to: Add more dots to all lines, ensuring the dots will go past a specific column Then, delete from a specific column until the end ...


2

I would define a function like function DotsToCol(col) abort " get rid of dots exe 'substitute/\.//' . (&gdefault ? '' : 'g') " find first digit normal! $bh " insert the rest of the dots execute 'normal!' (a:col - col('$') + (col('$')-col('.'))).'i.' endfunction And do, e.g., :%call DotsToCol(50). I get (note it didn't handle ...


Top 50 recent answers are included