Posts tagged: regex

All posts with the tag "regex"

4 posts latest post 2024-10-08
Publishing rhythm
Oct 2024 | 1 posts
Support regex substitution command · Issue #2232 · helix-editor/helix Support regex substitution, comparable to vim :s or VSCode search & replace. I propose supporting regex replacements for selection s, files/, and the workspace scopes + /. This could be acc... GitHub · github.com [1] Here is a really good vim substitute with regex capture groups, saving this one for a rainy day. * Reading 1: This is a title to a link * Reading 2: This is another title :%s/\v(: )(.+)$/\1\[\2\]\( * Reading 1: [This is a title to a link]( * Reading 2: [This is another title]( Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://github.com/helix-editor/helix/issues/2232#issuecomment-1228632218 [2]: /thoughts/
- I’ve heard prime say just give it the one eyed fighting kirby so many times, and execute it few times, and there is no way to find it online, so this will be the link that I will come to, when I need to remember what @theprimeagen means when he says Give it the one eyed fighting kirby. :s/\(.*\);/console.log(\1) So what is this? # [1] This is a vim substitute comand to replace text in the buffer. the one eyed fighting kirby is a regex capture group to capture everything between matches, and assign it a value to place back in after the match. substitute in a nutshell, :s/<what you want to replace>/<what you want to replace with> More examples # [2] Here is a contrived example of text. here there from here go there here = some_fuction(there) Now for some reason I want to switch all of the words here and there. I can do that with three capture groups, \1 is here, \2 is everything between, \3 is there. :%s/\(here\)\(.*\)\(there\)/\3\2\1 Just give it the one eyed fighting kirby ~Prime still struggling # [3] I thought this explaination from phind was good and more verbose than mine. --- describe this vim substitute regex :%s/(here)(.)(there)/\3\2\1 ANSWER | PHIND V9 M...
External Link X (formerly Twitter) · twitter.com [1] I need to learn regex capture groups better. This is so dang powerful. I really like the \v that bob uses here, it really does cut down on the terseness of all the special characters. I wanted to replace all occurrences of: name,[email protected],0,171,,2023-09-21 With: name,[email protected] Easy to do with Python, but what about a bit of > regex in Vim? :%s/\v([^,]+,[^,]+),.*/\1/ Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://twitter.com/bbelderbos/status/1709525676154368055 [2]: /thoughts/