Skip to main content
Share Your Experience: Take the 2024 Developer Survey

New answers tagged

2 votes

Double numbers on all matching lines containing text pattern

Woah, three answers already and not a mention of :g. Double numbers on all matching lines containing text pattern Is just a special case of: Execute <command> on all lines matching <...
romainl's user avatar
  • 41k
3 votes

Double numbers on all matching lines containing text pattern

Regular expressions? Yuck! Here's a non-regex version: Starting from any line with a number on it type: qqCtrl-ACtrl-XciwCtrl-R=Ctrl-R-*2EnterEscqu Then run the command: :g/Experience points:/norm!@q ...
Rich's user avatar
  • 32.1k
2 votes

Double numbers on all matching lines containing text pattern

I would do: :%s/Experience points: \zs(\d\+)/\=submatch(1)*2/g As already mentioned the pattern not found is because + need to be escaped in Vim To make sure you not lose the Experience points: we ...
Vivian De Smedt's user avatar
3 votes
Accepted

Double numbers on all matching lines containing text pattern

%s/\(Experience points: \)\@<=\(\d\+\)/\=submatch(2)*2/g \(...\)@<= is anchoring point \+ instead of + is used to match more than 1 occurence
Eric Sun's user avatar
  • 198
3 votes

How do I make Vim do spell-check only in words that beings with [a-zA-Z] and continues on with [a-z]?

If not better, then at least there is a simpler method to achieve this thing(not making words like 'alexanderSupertramp' marked wrongly spelled by default). :setlocal spelloption=camel Using this ...
souraj ghosh's user avatar
0 votes
Accepted

How do I make Vim do spell-check only in words that beings with [a-zA-Z] and continues on with [a-z]?

I would mark the NoSpell words: syn match myExCapitalWords /\<\l\+\u\w*\>/ contains=@NoSpell These marks the words that include an Uppercase letter somewhere in the middle of the word as not to ...
Vivian De Smedt's user avatar

Top 50 recent answers are included