{"id":13758,"date":"2024-12-17T06:28:38","date_gmt":"2024-12-17T06:28:38","guid":{"rendered":"https:\/\/www.bodhost.com\/kb\/?p=13758"},"modified":"2026-02-26T14:02:09","modified_gmt":"2026-02-26T14:02:09","slug":"how-to-undo-and-redo-changes-in-vim-vi","status":"publish","type":"post","link":"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/","title":{"rendered":"How to Undo and Redo Changes in Vim \/ Vi"},"content":{"rendered":"<p>Vim and Vi provide powerful undo and redo functionality, allowing users to navigate their edit history easily. This guide will cover the essential commands and techniques for managing changes in your text.<\/p>\n<p><strong>Basic Undo and Redo Commands<\/strong><\/p>\n<p><strong>Undo Changes<\/strong><br \/>\n&#8211; `u`: Undo the last change<br \/>\n&#8211; `U`: Undo all changes on the current line (since the line was entered)<\/p>\n<p><strong>Redo Changes<\/strong><br \/>\n&#8211; `Ctrl + R`: Redo the previously undone change<br \/>\n&#8211; `:redo`: Alternative command to redo changes<\/p>\n<p><strong>Advanced Undo and Redo Techniques<\/strong><\/p>\n<p><strong>Multiple Undos<\/strong><br \/>\n&#8211; `5u`: Undo the last 5 changes<br \/>\n&#8211; `:undolist`: View a list of undo branches<\/p>\n<p><strong>Undo Branches<\/strong><br \/>\nVim supports a tree-like undo history, allowing you to explore different modification paths:<br \/>\n&#8211; `:earlier 10m`: Revert to the state 10 minutes ago<br \/>\n&#8211; `:later 5m`: Move forward in time by 5 minutes<br \/>\n&#8211; `g-`: Move backward in the undo tree<br \/>\n&#8211; `g+`: Move forward in the undo tree<\/p>\n<p><strong>Persistent Undo<\/strong><\/p>\n<p><strong>Enabling Persistent Undo<\/strong><br \/>\nAdd these lines to your `.vimrc` file to enable persistent undo:<br \/>\n&#8220;`vim<br \/>\nset undodir=~\/.vim\/undodir<br \/>\nset undofile<br \/>\nset undolevels=1000<br \/>\nset undoreload=10000<br \/>\n&#8220;`<\/p>\n<p><strong>Benefits of Persistent Undo<\/strong><br \/>\n&#8211; Preserves undo history between editing sessions<br \/>\n&#8211; Allows recovery of changes after closing and reopening a file<\/p>\n<p><strong>Common Undo\/Redo Scenarios<\/strong><\/p>\n<p><strong>Recovering from Accidental Deletions<\/strong><br \/>\n&#8211; `u`: Quickly undo the last deletion<br \/>\n&#8211; `Ctrl + R`: Restore the deleted content if accidentally undone<\/p>\n<p><strong>Exploring Edit History<\/strong><br \/>\n1. Make multiple changes<br \/>\n2. Use `u` to step backward<br \/>\n3. Use `Ctrl + R` to step forward<\/p>\n<p><strong>Best Practices<\/strong><br \/>\n&#8211; Regularly use undo to experiment with changes<br \/>\n&#8211; Utilize `:undolist` to understand your edit history<br \/>\n&#8211; Configure persistent undo for long-term edit tracking<\/p>\n<p><strong>Troubleshooting<\/strong><\/p>\n<p><strong>Undo Not Working?<\/strong><br \/>\n&#8211; Ensure you&#8217;re in Normal mode<br \/>\n&#8211; Check Vim version (persistent undo requires Vim 7.3+)<br \/>\n&#8211; Verify `.vimrc` configuration<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>Mastering undo and redo in Vim\/Vi improves text editing efficiency. Practice these commands to become more comfortable with navigating your edit history.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vim and Vi provide powerful undo and redo functionality, allowing users to navigate their edit history easily. This guide will cover the essential commands and techniques for managing changes in&hellip;<\/p>\n<p><a href=\"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/\" class=\"more-link\">Read More<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[666],"tags":[1588],"class_list":["post-13758","post","type-post","status-publish","format-standard","hentry","category-general","tag-undo-and-redo-changes-in-vim-vi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Use Undo and Redo Commands in Vim\/Vi Like a Pro<\/title>\n<meta name=\"description\" content=\"Vim and Vi provide powerful undo and redo functionality, allowing users to navigate their edit history easily.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use Undo and Redo Commands in Vim\/Vi Like a Pro\" \/>\n<meta property=\"og:description\" content=\"Vim and Vi provide powerful undo and redo functionality, allowing users to navigate their edit history easily.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/\" \/>\n<meta property=\"og:site_name\" content=\"Knowledge Base - bodHOST\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-17T06:28:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-26T14:02:09+00:00\" \/>\n<meta name=\"author\" content=\"Paul Lopez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Lopez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-undo-and-redo-changes-in-vim-vi\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-undo-and-redo-changes-in-vim-vi\\\/\"},\"author\":{\"name\":\"Paul Lopez\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/566ccff9a2fae4af852be8097b179813\"},\"headline\":\"How to Undo and Redo Changes in Vim \\\/ Vi\",\"datePublished\":\"2024-12-17T06:28:38+00:00\",\"dateModified\":\"2026-02-26T14:02:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-undo-and-redo-changes-in-vim-vi\\\/\"},\"wordCount\":319,\"publisher\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\"},\"keywords\":[\"Undo and Redo Changes in Vim \\\/ Vi\"],\"articleSection\":[\"General Discussion\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-undo-and-redo-changes-in-vim-vi\\\/\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-undo-and-redo-changes-in-vim-vi\\\/\",\"name\":\"How to Use Undo and Redo Commands in Vim\\\/Vi Like a Pro\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#website\"},\"datePublished\":\"2024-12-17T06:28:38+00:00\",\"dateModified\":\"2026-02-26T14:02:09+00:00\",\"description\":\"Vim and Vi provide powerful undo and redo functionality, allowing users to navigate their edit history easily.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-undo-and-redo-changes-in-vim-vi\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-undo-and-redo-changes-in-vim-vi\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-undo-and-redo-changes-in-vim-vi\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"General Discussion\",\"item\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/category\\\/general\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Undo and Redo Changes in Vim \\\/ Vi\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/\",\"name\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\"},\"alternateName\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\",\"name\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/Profile-Pic.png\",\"contentUrl\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/Profile-Pic.png\",\"width\":240,\"height\":240,\"caption\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\"},\"image\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/566ccff9a2fae4af852be8097b179813\",\"name\":\"Paul Lopez\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c63d9f5400cd5ef87b481a24b2c1a4fb89f1674b6391325326cf13f1e735dff8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c63d9f5400cd5ef87b481a24b2c1a4fb89f1674b6391325326cf13f1e735dff8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c63d9f5400cd5ef87b481a24b2c1a4fb89f1674b6391325326cf13f1e735dff8?s=96&d=mm&r=g\",\"caption\":\"Paul Lopez\"},\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/author\\\/paullopez\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Use Undo and Redo Commands in Vim\/Vi Like a Pro","description":"Vim and Vi provide powerful undo and redo functionality, allowing users to navigate their edit history easily.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/","og_locale":"en_US","og_type":"article","og_title":"How to Use Undo and Redo Commands in Vim\/Vi Like a Pro","og_description":"Vim and Vi provide powerful undo and redo functionality, allowing users to navigate their edit history easily.","og_url":"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/","og_site_name":"Knowledge Base - bodHOST","article_published_time":"2024-12-17T06:28:38+00:00","article_modified_time":"2026-02-26T14:02:09+00:00","author":"Paul Lopez","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Paul Lopez","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/#article","isPartOf":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/"},"author":{"name":"Paul Lopez","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/person\/566ccff9a2fae4af852be8097b179813"},"headline":"How to Undo and Redo Changes in Vim \/ Vi","datePublished":"2024-12-17T06:28:38+00:00","dateModified":"2026-02-26T14:02:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/"},"wordCount":319,"publisher":{"@id":"https:\/\/www.bodhost.com\/kb\/#organization"},"keywords":["Undo and Redo Changes in Vim \/ Vi"],"articleSection":["General Discussion"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/","url":"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/","name":"How to Use Undo and Redo Commands in Vim\/Vi Like a Pro","isPartOf":{"@id":"https:\/\/www.bodhost.com\/kb\/#website"},"datePublished":"2024-12-17T06:28:38+00:00","dateModified":"2026-02-26T14:02:09+00:00","description":"Vim and Vi provide powerful undo and redo functionality, allowing users to navigate their edit history easily.","breadcrumb":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.bodhost.com\/kb\/how-to-undo-and-redo-changes-in-vim-vi\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"General Discussion","item":"https:\/\/www.bodhost.com\/kb\/category\/general\/"},{"@type":"ListItem","position":2,"name":"How to Undo and Redo Changes in Vim \/ Vi"}]},{"@type":"WebSite","@id":"https:\/\/www.bodhost.com\/kb\/#website","url":"https:\/\/www.bodhost.com\/kb\/","name":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","description":"","publisher":{"@id":"https:\/\/www.bodhost.com\/kb\/#organization"},"alternateName":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.bodhost.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.bodhost.com\/kb\/#organization","name":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","url":"https:\/\/www.bodhost.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/www.bodhost.com\/kb\/wp-content\/uploads\/2025\/10\/Profile-Pic.png","contentUrl":"https:\/\/www.bodhost.com\/kb\/wp-content\/uploads\/2025\/10\/Profile-Pic.png","width":240,"height":240,"caption":"Web Hosting Knowledge Base | bodHOST Hosting FAQ"},"image":{"@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/person\/566ccff9a2fae4af852be8097b179813","name":"Paul Lopez","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c63d9f5400cd5ef87b481a24b2c1a4fb89f1674b6391325326cf13f1e735dff8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c63d9f5400cd5ef87b481a24b2c1a4fb89f1674b6391325326cf13f1e735dff8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c63d9f5400cd5ef87b481a24b2c1a4fb89f1674b6391325326cf13f1e735dff8?s=96&d=mm&r=g","caption":"Paul Lopez"},"url":"https:\/\/www.bodhost.com\/kb\/author\/paullopez\/"}]}},"_links":{"self":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/13758","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/comments?post=13758"}],"version-history":[{"count":3,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/13758\/revisions"}],"predecessor-version":[{"id":13761,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/13758\/revisions\/13761"}],"wp:attachment":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/media?parent=13758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/categories?post=13758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/tags?post=13758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}