{"id":4372,"date":"2025-06-24T05:45:58","date_gmt":"2025-06-24T05:45:58","guid":{"rendered":"https:\/\/w3buddy.com\/?p=4372"},"modified":"2026-01-15T12:52:13","modified_gmt":"2026-01-15T07:22:13","slug":"how-to-delete-multiple-lines-in-vi-editor","status":"publish","type":"post","link":"https:\/\/w3buddy.com\/blog\/how-to-delete-multiple-lines-in-vi-editor\/","title":{"rendered":"How to Delete Multiple Lines in vi Editor"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">When you&#8217;re editing a file in <code>vi<\/code> (or <code>vim<\/code>) and come across a large block of unnecessary lines\u2014such as logs, commented code, or config entries\u2014you might want to delete several lines at once.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Instead of deleting them one by one, you can remove <strong>N lines instantly<\/strong> from your current cursor position.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Command Format:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>Ndd<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>N<\/code><\/strong> = number of lines to delete<\/li>\n\n\n\n<li><strong><code>dd<\/code><\/strong> = delete command<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Example:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To delete 10 lines starting from the current line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>10dd<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Steps:<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Press <code>Esc<\/code> to ensure you&#8217;re in <strong>normal mode<\/strong>.<\/li>\n\n\n\n<li>Type the number (<code>N<\/code>) of lines you want to delete.<\/li>\n\n\n\n<li>Then press <code>d<\/code> and <code>d<\/code>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>Press \u2192  1  0  d  d\n<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And you&#8217;re done \u2014 10 lines gone in one shot!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you&#8217;re editing a file in vi (or vim) and come across a large block of unnecessary lines\u2014such as logs, commented code, or config entries\u2014you might want to delete several lines at once. Instead of deleting them one by one, you can remove N lines instantly from your current cursor position. Command Format: Example: To [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"googlesitekit_rrm_CAowu461DA:productID":"","footnotes":""},"categories":[1225],"tags":[],"class_list":["post-4372","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts\/4372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/comments?post=4372"}],"version-history":[{"count":1,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts\/4372\/revisions"}],"predecessor-version":[{"id":4373,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts\/4372\/revisions\/4373"}],"wp:attachment":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/media?parent=4372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=4372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/tags?post=4372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}