{"id":1116,"date":"2021-04-08T09:46:26","date_gmt":"2021-04-08T09:46:26","guid":{"rendered":"https:\/\/codeinsightacademy.com\/blog\/?p=1116"},"modified":"2022-08-03T08:17:29","modified_gmt":"2022-08-03T08:17:29","slug":"vim-cheat-sheet","status":"publish","type":"post","link":"https:\/\/codeinsightacademy.com\/blog\/linux\/vim-cheat-sheet\/","title":{"rendered":"vim cheat sheet"},"content":{"rendered":"\n<p>to open file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim filename<\/code><\/pre>\n\n\n\n<p>copy\/cut paste<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yy => p\ndd => p\nv => select lines to copy => y => goto line where need to paste => p\nv => select lines to cut => d => goto line where need to paste => p\n<\/code><\/pre>\n\n\n\n<p>to undo and redo<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Esc\nu u u u \n\nEsc\nCtrl + R Ctrl + R<\/code><\/pre>\n\n\n\n<p>to open file in read mode<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim -R filename<\/code><\/pre>\n\n\n\n<p>to open file on specific line number<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim filename +10<\/code><\/pre>\n\n\n\n<p>insert mode<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>i\no<\/code><\/pre>\n\n\n\n<p>escape \/ command mode<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Esc<\/code><\/pre>\n\n\n\n<p>to write file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:w\n:wq\n:x<\/code><\/pre>\n\n\n\n<p>to minimize vim editor<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Ctrl + Z<\/code><\/pre>\n\n\n\n<p>to see minimized files in vim<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>jobs<\/code><\/pre>\n\n\n\n<p>to see background job<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bg<\/code><\/pre>\n\n\n\n<p>to open specific jobs or bring it to <strong>f<\/strong>ore<strong>g<\/strong>round<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fg 1\nfg +\nfg -<\/code><\/pre>\n\n\n\n<p>search any word in vim editor<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/word\n\/word\\c\n\/word\\C\n#then press N or Shift + N<\/code><\/pre>\n\n\n\n<p>search and replace word<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:%s\/word\/replacewith\/i\n:%s\/word\/replacewith\/g<\/code><\/pre>\n\n\n\n<p>go to specific line<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:10\n:1\n:$<\/code><\/pre>\n\n\n\n<p>show\/hide line numbers in vim editor<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:set number\n:set nonumber<\/code><\/pre>\n\n\n\n<p>set tabstop<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:set tabstop=4<\/code><\/pre>\n\n\n\n<p>set font color<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:colorscheme murphy<\/code><\/pre>\n\n\n\n<p>vimdiff difference between 2 files<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vimdiff file1 file2\n#difference put\ndp\n#difference obtain\ndo<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>to open file copy\/cut paste to undo and redo to open file in read mode to open file on specific line number insert mode escape \/ command mode to write file to minimize vim editor to see minimized files in vim to see background job to open specific jobs or bring it to foreground search [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[31],"tags":[],"_links":{"self":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/1116"}],"collection":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/comments?post=1116"}],"version-history":[{"count":9,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/1116\/revisions"}],"predecessor-version":[{"id":2291,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/1116\/revisions\/2291"}],"wp:attachment":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/media?parent=1116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/categories?post=1116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/tags?post=1116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}