{"id":10992,"date":"2023-12-05T09:52:31","date_gmt":"2023-12-05T08:52:31","guid":{"rendered":"https:\/\/monodes.com\/predaelli\/?p=10992"},"modified":"2023-12-05T09:52:36","modified_gmt":"2023-12-05T08:52:36","slug":"search-and-replace-in-multiple-files-using-vim","status":"publish","type":"post","link":"https:\/\/monodes.com\/predaelli\/2023\/12\/05\/search-and-replace-in-multiple-files-using-vim\/","title":{"rendered":"Search and replace in multiple files using vim"},"content":{"rendered":"\n<p><em><a href=\"https:\/\/stackoverflow.com\/questions\/37424689\/search-and-replace-in-multiple-files-using-vim\">Search and replace in multiple files using vim &#8211; (source Stack Overflow)<\/a><\/em><\/p>\n\n\n\n<p>It is as simple as<\/p>\n\n\n\n<p>Use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\" data-line=\"\">:set aw\n:argdo %s\/happy999\/happy111\/g\n<\/code><\/pre>\n\n\n\n<p>The first line sets auto-write mode, so when you switch between files, <code class=\"\" data-line=\"\">vim<\/code> will write the file if it has changed.<\/p>\n\n\n\n<p>The second line does your global search and replace.<\/p>\n\n\n\n<p>Note that it doesn&#8217;t use <code class=\"\" data-line=\"\">wq!<\/code> since that exits. If you don&#8217;t want to use auto-write, then you could use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\" data-line=\"\">:argdo %s\/happy999\/happy111\/g | w\n<\/code><\/pre>\n\n\n\n<p>This avoids terminating <code class=\"\" data-line=\"\">vim<\/code> at the end of editing the first file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">Search and replace in multiple files using vim &#8211; (source Stack Overflow) It is as simple as Use: The first line sets auto-write mode, so when you switch between files, vim will write the file if it has changed. The second line does your global search and replace. Note that it doesn&#8217;t use wq! since&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/monodes.com\/predaelli\/2023\/12\/05\/search-and-replace-in-multiple-files-using-vim\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[72,278],"tags":[55],"class_list":["post-10992","post","type-post","status-publish","format-standard","hentry","category-documentations","category-tricks","tag-vim"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6daft-2Ri","jetpack-related-posts":[{"id":8003,"url":"https:\/\/monodes.com\/predaelli\/2021\/01\/04\/5-lines-i-put-in-a-blank-vimrc-sword-and-signals\/","url_meta":{"origin":10992,"position":0},"title":"5 lines I put in a blank .vimrc | Sword and Signals","author":"Paolo Redaelli","date":"2021-01-04","format":false,"excerpt":"TL;DR To make a default Vim installation more useful, type the following 5 lines into its .vimrc file: set hlsearch \" highlight all search results set ignorecase \" do case insensitive search set incsearch \" show incremental search results as you type set number \" display line number set noswapfile\u2026","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10923,"url":"https:\/\/monodes.com\/predaelli\/2023\/10\/24\/5-must-have-vim-plugins-that-will-change-your-workflow\/","url_meta":{"origin":10992,"position":1},"title":"5 Must-Have Vim Plugins That Will Change Your Workflow","author":"Paolo Redaelli","date":"2023-10-24","format":false,"excerpt":"5 Must-Have Vim Plugins That Will Change Your Workflow. In my case Syntastic: a syntax checking plugin for Vim which runs files through external syntax checkers and displays resulting errors. Fugitive: a Git wrapper for Vim that is self-described as \"so awesome, it should be illegal.\" Emmet: an extremely useful\u2026","rel":"","context":"In &quot;Tricks&quot;","block_context":{"text":"Tricks","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/tricks\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1507,"url":"https:\/\/monodes.com\/predaelli\/2016\/05\/07\/learning-vim\/","url_meta":{"origin":10992,"position":2},"title":"Learning VIM","author":"Paolo Redaelli","date":"2016-05-07","format":false,"excerpt":"She likes to write on the terminal. She is learning VIM. She is 6 years old.","rel":"","context":"In &quot;Mood&quot;","block_context":{"text":"Mood","link":"https:\/\/monodes.com\/predaelli\/category\/mood\/"},"img":{"alt_text":"silvia-usa-vim","src":"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2016\/05\/silvia-usa-vim-510x302.jpeg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1895,"url":"https:\/\/monodes.com\/predaelli\/2016\/11\/15\/50-most-frequently-used-unix-linux-commands-with-examples\/","url_meta":{"origin":10992,"position":3},"title":"50 Most Frequently Used UNIX \/ Linux Commands (With Examples)","author":"Paolo Redaelli","date":"2016-11-15","format":false,"excerpt":"Several pearl in 50 Most Frequently Used UNIX \/ Linux Commands (With Examples) Add line number for all non-empty-lines in a file $ sed '\/.\/=' thegeekstuff.txt | sed 'N; s\/\\n\/ \/' Remove duplicate lines using awk $ awk '!($0 in array) { array[$0]; print }' temp \u00a0 Print all lines\u2026","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5144,"url":"https:\/\/monodes.com\/predaelli\/2019\/01\/22\/5144\/","url_meta":{"origin":10992,"position":4},"title":"How do I paste from PuTTY into Vim 8.0?","author":"Paolo Redaelli","date":"2019-01-22","format":false,"excerpt":"How do I paste from PuTTY into Vim 8.0? Well, nice question, as I found it quite annoying that the usual right click on the mouse doesn't work. In fact Open a web browser, copy \/ paste some text from a website (eg. GitHub) Use PuTTY 0.67 to SSH to\u2026","rel":"","context":"In &quot;Senza categoria&quot;","block_context":{"text":"Senza categoria","link":"https:\/\/monodes.com\/predaelli\/category\/senza-categoria\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1037,"url":"https:\/\/monodes.com\/predaelli\/2016\/02\/21\/vim-master-cheat-sheet\/","url_meta":{"origin":10992,"position":5},"title":"Vim master cheat sheet","author":"Paolo Redaelli","date":"2016-02-21","format":false,"excerpt":"Sorgente: Vim by Patrick Schanen | ZEEF Vim, an open-source, powerful and configurable text editor.","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/10992","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/comments?post=10992"}],"version-history":[{"count":0,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/10992\/revisions"}],"wp:attachment":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/media?parent=10992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/categories?post=10992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/tags?post=10992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}