{"id":871,"date":"2022-01-24T22:54:38","date_gmt":"2022-01-24T17:24:38","guid":{"rendered":"https:\/\/mutesoft.com\/spaces\/software\/?p=871"},"modified":"2022-04-19T13:19:05","modified_gmt":"2022-04-19T07:49:05","slug":"vi-goto-line","status":"publish","type":"post","link":"https:\/\/mutesoft.com\/spaces\/software\/vi-goto-line.html","title":{"rendered":"vi goto line"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mutesoft.com\/spaces\/software\/vi-goto-line.html\/#1_Context\" >1. Context<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mutesoft.com\/spaces\/software\/vi-goto-line.html\/#2_vi_goto_line\" >2. vi goto line<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mutesoft.com\/spaces\/software\/vi-goto-line.html\/#21_vi_goto_a_specific_line\" >2.1 vi goto a specific line<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mutesoft.com\/spaces\/software\/vi-goto-line.html\/#22_vi_goto_start_of_file\" >2.2 vi goto start of file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mutesoft.com\/spaces\/software\/vi-goto-line.html\/#23_vi_goto_end_of_file\" >2.3 vi goto end of file<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mutesoft.com\/spaces\/software\/vi-goto-line.html\/#3_Conclusion\" >3. Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"1-context\"><span class=\"ez-toc-section\" id=\"1_Context\"><\/span>1. Context<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Knowing the commonly used vi editor commands is absolute bliss. You can get your work done much faster with frequently used commands. The command to go to a specific line is one of those frequently used commands.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2022\/01\/vi-editor.png\"><img decoding=\"async\" src=\"https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2022\/01\/vi-editor.png\" alt=\"\" class=\"wp-image-881\" width=\"1200\" srcset=\"https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2022\/01\/vi-editor.png 1008w, https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2022\/01\/vi-editor-300x188.png 300w, https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2022\/01\/vi-editor-768x480.png 768w\" sizes=\"(max-width: 1008px) 100vw, 1008px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>If the vi editor is not yet opened, use the <code>vi<\/code> command to open the editor. Then use one of the many options to go to a specific line. All the commands used here apply to the  <code>vim<\/code> editor as well.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># vi to open the editor\nvi\n\n# vi FILE_PATH to open a file in vi editor\nvi \/home\/profile\/myfile.txt\n\n# vim FILE_PATH to open a file in vim editor\nvim \/home\/profile\/myfile.txt<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-vi-goto-line\"><span class=\"ez-toc-section\" id=\"2_vi_goto_line\"><\/span>2. vi goto line<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p> For line navigation, here are some scenarios:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>go to a specific line <\/li><li>go to the first line of the file<\/li><li>go to the last line of the file<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-1-vi-goto-a-specific-line\"><span class=\"ez-toc-section\" id=\"21_vi_goto_a_specific_line\"><\/span>2.1 vi goto a specific line<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>First, press the <code>Esc<\/code> key to switch to the command mode. Then either use <code>nG<\/code> or <code>:n<\/code> to go to n<sup>th<\/sup> line.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Switch to the command mode\nEsc\n\n# :line_number\n:10 (to go to 10th line)\n\n# Alternate command to use line_numberG\n15G (to go to 15th line)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-2-vi-goto-start-of-file\"><span class=\"ez-toc-section\" id=\"22_vi_goto_start_of_file\"><\/span>2.2 vi goto start of file<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>First, press the <code>Esc<\/code> key to switch to the command mode. Then press <code>gg<\/code> to go to the first line of the file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Switch to the command mode\nEsc\n\n# Go to the first line of the file\ngg<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-3-vi-goto-end-of-file\"><span class=\"ez-toc-section\" id=\"23_vi_goto_end_of_file\"><\/span>2.3 vi goto end of file<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>First, press the <code>Esc<\/code> key to switch to the command mode. Then press the key <code>G<\/code>  (<code>Shift + G<\/code>) to go to the last line of the file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Switch to the command mode\nEsc\n\n# Go to the last line of the file (Shift + G)\nG<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-conclusion\"><span class=\"ez-toc-section\" id=\"3_Conclusion\"><\/span>3. Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To work with the <code>vi<\/code> editor like a pro, refer to this article: <a href=\"https:\/\/mutesoft.com\/spaces\/software\/work-with-vi-editor-like-a-pro.html\" data-type=\"post\" data-id=\"794\">Work With vi Editor Like a Pro<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Knowing the commonly used vi editor commands is absolute bliss. You can get your work done much faster with frequently used commands. The command to go to a specific line is one of those frequently used commands.<\/p>\n","protected":false},"author":2,"featured_media":881,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"Knowing the commonly used vi editor commands is absolute bliss. You can get your work done much faster with frequently used commands. The command to go to a specific line is one of those frequently used commands.","_seopress_robots_index":"","_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"categories":[6,32],"tags":[49,46,47,42,43],"class_list":["post-871","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","category-tools","tag-shortcut-keys","tag-top-vi-commands","tag-top-vim-commands","tag-vi-editor","tag-vim-editor"],"_links":{"self":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/comments?post=871"}],"version-history":[{"count":22,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/871\/revisions"}],"predecessor-version":[{"id":1144,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/871\/revisions\/1144"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/media\/881"}],"wp:attachment":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/media?parent=871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/categories?post=871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/tags?post=871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}