Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
¿Cómo volver a numerar líneas usando un comando vi?

Estoy tratando de volver a numerar las líneas 2,$ en un archivo usando el comando vim a, conozco el comando cat -n de nl, puedo numerar las líneas, pero no obtuve el resultado esperado:

Probé esto :2,$s/^\([^,]\)// | 2,$!cat -n

aporte:

 #,Name,Types,Total,HP,Attack,Weaknesses,Strength 493,Arceus,Normal,720,120,120,Fighting,strong 483,Dialga,Steel;Dragon,680,100,120,Fighting;Ground,strong 250,Ho-oh,Fire;Flying,680,106,130,Electric;Water;Rock,strong .... moer 100 lines

Rendimiento esperado:

 #,Name,Types,Total,HP,Attack,Weaknesses,Strength 1,Arceus,Normal,720,120,120,Fighting,strong 2,Dialga,Steel;Dragon,680,100,120,Fighting;Ground,strong 3,Ho-oh,Fire;Flying,680,106,130,Electric;Water;Rock,strong ....
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede usar \= para usar una sub-replace-expression y line('.') para obtener el número de línea actual:

 " The parenthesis around `line('.')-1` are not needed, but it seems clearer to me :2,$s/^/\=(line('.')-1).','/

Editar: me acabo de dar cuenta de que en realidad está reemplazando su primera columna, por lo que es posible que desee

 :2,$s/^\d\+/\=line('.')-1/
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!