Skip to main content
7 events
when toggle format what by license comment
Jun 2, 2023 at 13:15 history edited D. Ben Knoble CC BY-SA 4.0
added 189 characters in body
Jun 2, 2023 at 13:13 comment added D. Ben Knoble It's not my answer. But I've pointed out what you need to change. You don't want to put anything after s//\=a/ except the | let a += 1; anything after the slash but before the bar becomes a syntax error. To change the pattern to ` 0 : Container` but change only the 0, write :let a = 1 | g/ \zs0\ze : Container(/s//\=a/ | let a += 1. This is why I recommend trying with just regular search / first, to make sure the pattern works as you want. Then, simply :let a = 1 | g//s//\=a/ | let a += 1. You keep trying to add pattern-ish things outside of where I showed @AdjunctProfessorFalcon
Jun 1, 2023 at 22:26 comment added AdjunctProfessorFalcon Obviously this works to match the pattern: g/ \d : Container( but I can't seem to insert the variable stuff in there. I've tried: let a = 10 | g// \d /s//\=a/ : Container( but then I get error like "misplaced ="
Jun 1, 2023 at 22:23 comment added AdjunctProfessorFalcon I don't understand your answer because you're just illustrating a solution that's the opposite of what I'm trying to do (which is to understand the correct syntax with the variable usage) if the pattern is inverted. The example you've provided is the same as your other answer to the other post.
Jun 1, 2023 at 22:13 comment added D. Ben Knoble The command you pasted is the same broken command from your question @AdjunctProfessorFalcon. You need to change the part between the slashes of global if you want to change the matched pattern. (I'm not going to do it for you, because I think it's a good exercise for you at this point.)
Jun 1, 2023 at 19:53 comment added AdjunctProfessorFalcon Thank you for responding to this! What if the pattern I wanted to match was "0 : Container(" and I wanted to increment the 0? Can I swap around the pattern and do: global/ \zs\d\+\ze,$/ substitute//\=a/ : Container( | let a += 1
Jun 1, 2023 at 19:49 history answered D. Ben Knoble CC BY-SA 4.0