{"id":454,"date":"2019-08-28T14:47:56","date_gmt":"2019-08-28T14:47:56","guid":{"rendered":"https:\/\/acampbell.uk\/wp\/?p=454"},"modified":"2021-06-19T07:06:31","modified_gmt":"2021-06-19T07:06:31","slug":"vim-how-to-avoid-hjkl-confusion-in-insert-mode","status":"publish","type":"post","link":"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/","title":{"rendered":"Vim &#8211; how to avoid hjkl confusion in Insert mode"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Are you a Vim user? Do you like to use the hjkl keys to move the cursor in Normal mode, like me? If you do, perhaps you&#8217;ve experienced the annoyance of forgetting that you are in Insert mode, only to find something like hhhhh or kkkkk appearing on the screen instead of the expected cursor movement. I have to admit that this still happens to me, even after many years. How can it be avoided?<\/p>\n<p>Vim experts advise that you should stay in Normal mode most of the time; it should be the default. I agree, and I do try to remember to do this.\u00a0 Another idea, which I&#8217;ve tried in the past, is to make key mappings such as Alt+h and Alt+l\u00a0 to move the cursor in both Insert and Normal modes and disable the defaults. But then you&#8217;ve lost the simplicity of the one-key hjkl which was the main reason to go down this route in the first place.<\/p>\n<p>The solution I&#8217;ve adopted is based on <em>&lt;https:\/\/stackoverflow.com\/questions\/7614546\/vim-cursorline-color-change-in-insert-mode&gt;.<\/em> Here is the code I&#8217;m using in .gvimrc with a dark colour scheme (Murphy). (The last character in the bottom line is a zero.)<\/p>\n<p><code>set cursorline<br \/>\nautocmd InsertEnter * highlight CursorLine guifg=white guibg=grey25<br \/>\nautocmd InsertLeave * highlight CursorLine guifg=white guibg=red<br \/>\nset guicursor+=n-v-c:blinkonO<\/code><\/p>\n<p>This gives a light grey cursor line in Insert mode which stand out on the dark background but not too starkly.<\/p>\n<figure id=\"attachment_573\" aria-describedby=\"caption-attachment-573\" style=\"width: 683px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" class=\"size-full wp-image-573\" src=\"https:\/\/acampbell.uk\/wp\/wp-content\/uploads\/2019\/08\/lorem1-1.png\" alt=\"\" width=\"683\" height=\"152\" srcset=\"https:\/\/acampbell.uk\/wp\/wp-content\/uploads\/2019\/08\/lorem1-1.png 683w, https:\/\/acampbell.uk\/wp\/wp-content\/uploads\/2019\/08\/lorem1-1-300x67.png 300w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><figcaption id=\"caption-attachment-573\" class=\"wp-caption-text\">Insert mode<\/figcaption><\/figure>\n<p>In Normal mode the cursor line becomes red.<\/p>\n<figure id=\"attachment_572\" aria-describedby=\"caption-attachment-572\" style=\"width: 684px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" class=\"size-full wp-image-572\" src=\"https:\/\/acampbell.uk\/wp\/wp-content\/uploads\/2019\/08\/lorem2-1.png\" alt=\"\" width=\"684\" height=\"182\" srcset=\"https:\/\/acampbell.uk\/wp\/wp-content\/uploads\/2019\/08\/lorem2-1.png 684w, https:\/\/acampbell.uk\/wp\/wp-content\/uploads\/2019\/08\/lorem2-1-300x80.png 300w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><figcaption id=\"caption-attachment-572\" class=\"wp-caption-text\">Normal mode<\/figcaption><\/figure>\n<p>I use the default cursor, which is block in Normal mode and 25% in Insert mode. Both are white; I&#8217;ve set the Normal mode cursor not to blink.<\/p>\n<p>I find that this set-up acts as an effective reminder of which mode I&#8217;m in.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp; Are you a Vim user? Do you like to use the hjkl keys to move the cursor in Normal mode, like me? If you do, perhaps you&#8217;ve experienced the annoyance of forgetting that you are in Insert mode, only to find something like hhhhh or kkkkk appearing on the screen instead of the &hellip; <a href=\"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Vim &#8211; how to avoid hjkl confusion in Insert mode&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"no","_lmt_disable":""},"categories":[7,13],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Vim - how to avoid hjkl confusion in Insert mode - Anthony Campbell&#039;s Blog 2<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Vim - how to avoid hjkl confusion in Insert mode - Anthony Campbell&#039;s Blog 2\" \/>\n<meta property=\"og:description\" content=\"&nbsp; &nbsp; Are you a Vim user? Do you like to use the hjkl keys to move the cursor in Normal mode, like me? If you do, perhaps you&#8217;ve experienced the annoyance of forgetting that you are in Insert mode, only to find something like hhhhh or kkkkk appearing on the screen instead of the &hellip; Continue reading &quot;Vim &#8211; how to avoid hjkl confusion in Insert mode&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/\" \/>\n<meta property=\"og:site_name\" content=\"Anthony Campbell&#039;s Blog 2\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-28T14:47:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-19T07:06:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/acampbell.uk\/wp\/wp-content\/uploads\/2019\/08\/lorem1-1.png\" \/>\n<meta name=\"author\" content=\"Anthony Campbell\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anthony Campbell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated 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:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/\"},\"author\":{\"name\":\"Anthony Campbell\",\"@id\":\"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/3bdb893c1c990948590f4ed9f30fee36\"},\"headline\":\"Vim &#8211; how to avoid hjkl confusion in Insert mode\",\"datePublished\":\"2019-08-28T14:47:56+00:00\",\"dateModified\":\"2021-06-19T07:06:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/\"},\"wordCount\":302,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/3bdb893c1c990948590f4ed9f30fee36\"},\"articleSection\":[\"computers\",\"vim\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/\",\"url\":\"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/\",\"name\":\"Vim - how to avoid hjkl confusion in Insert mode - Anthony Campbell&#039;s Blog 2\",\"isPartOf\":{\"@id\":\"https:\/\/acampbell.uk\/wp\/#website\"},\"datePublished\":\"2019-08-28T14:47:56+00:00\",\"dateModified\":\"2021-06-19T07:06:31+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/acampbell.uk\/wp\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Vim &#8211; how to avoid hjkl confusion in Insert mode\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/acampbell.uk\/wp\/#website\",\"url\":\"https:\/\/acampbell.uk\/wp\/\",\"name\":\"Anthony Campbell&#039;s Blog 2\",\"description\":\"My modest contribution to keeping alive the values of the Enlightenment\",\"publisher\":{\"@id\":\"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/3bdb893c1c990948590f4ed9f30fee36\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/acampbell.uk\/wp\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/3bdb893c1c990948590f4ed9f30fee36\",\"name\":\"Anthony Campbell\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2ecb7db399f5568043edb7868078fdd7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2ecb7db399f5568043edb7868078fdd7?s=96&d=mm&r=g\",\"caption\":\"Anthony Campbell\"},\"logo\":{\"@id\":\"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/www.acampbell.uk\",\"https:\/\/en.wikipedia.org\/wiki\/Anthony_Campbell_(physician)\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Vim - how to avoid hjkl confusion in Insert mode - Anthony Campbell&#039;s Blog 2","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:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/","og_locale":"en_GB","og_type":"article","og_title":"Vim - how to avoid hjkl confusion in Insert mode - Anthony Campbell&#039;s Blog 2","og_description":"&nbsp; &nbsp; Are you a Vim user? Do you like to use the hjkl keys to move the cursor in Normal mode, like me? If you do, perhaps you&#8217;ve experienced the annoyance of forgetting that you are in Insert mode, only to find something like hhhhh or kkkkk appearing on the screen instead of the &hellip; Continue reading \"Vim &#8211; how to avoid hjkl confusion in Insert mode\"","og_url":"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/","og_site_name":"Anthony Campbell&#039;s Blog 2","article_published_time":"2019-08-28T14:47:56+00:00","article_modified_time":"2021-06-19T07:06:31+00:00","og_image":[{"url":"https:\/\/acampbell.uk\/wp\/wp-content\/uploads\/2019\/08\/lorem1-1.png"}],"author":"Anthony Campbell","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Anthony Campbell","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/#article","isPartOf":{"@id":"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/"},"author":{"name":"Anthony Campbell","@id":"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/3bdb893c1c990948590f4ed9f30fee36"},"headline":"Vim &#8211; how to avoid hjkl confusion in Insert mode","datePublished":"2019-08-28T14:47:56+00:00","dateModified":"2021-06-19T07:06:31+00:00","mainEntityOfPage":{"@id":"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/"},"wordCount":302,"commentCount":0,"publisher":{"@id":"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/3bdb893c1c990948590f4ed9f30fee36"},"articleSection":["computers","vim"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/","url":"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/","name":"Vim - how to avoid hjkl confusion in Insert mode - Anthony Campbell&#039;s Blog 2","isPartOf":{"@id":"https:\/\/acampbell.uk\/wp\/#website"},"datePublished":"2019-08-28T14:47:56+00:00","dateModified":"2021-06-19T07:06:31+00:00","breadcrumb":{"@id":"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/acampbell.uk\/wp\/2019\/08\/28\/vim-how-to-avoid-hjkl-confusion-in-insert-mode\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/acampbell.uk\/wp\/"},{"@type":"ListItem","position":2,"name":"Vim &#8211; how to avoid hjkl confusion in Insert mode"}]},{"@type":"WebSite","@id":"https:\/\/acampbell.uk\/wp\/#website","url":"https:\/\/acampbell.uk\/wp\/","name":"Anthony Campbell&#039;s Blog 2","description":"My modest contribution to keeping alive the values of the Enlightenment","publisher":{"@id":"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/3bdb893c1c990948590f4ed9f30fee36"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/acampbell.uk\/wp\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/3bdb893c1c990948590f4ed9f30fee36","name":"Anthony Campbell","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2ecb7db399f5568043edb7868078fdd7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2ecb7db399f5568043edb7868078fdd7?s=96&d=mm&r=g","caption":"Anthony Campbell"},"logo":{"@id":"https:\/\/acampbell.uk\/wp\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/www.acampbell.uk","https:\/\/en.wikipedia.org\/wiki\/Anthony_Campbell_(physician)"]}]}},"modified_by":"Anthony Campbell","_links":{"self":[{"href":"https:\/\/acampbell.uk\/wp\/wp-json\/wp\/v2\/posts\/454"}],"collection":[{"href":"https:\/\/acampbell.uk\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/acampbell.uk\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/acampbell.uk\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/acampbell.uk\/wp\/wp-json\/wp\/v2\/comments?post=454"}],"version-history":[{"count":32,"href":"https:\/\/acampbell.uk\/wp\/wp-json\/wp\/v2\/posts\/454\/revisions"}],"predecessor-version":[{"id":921,"href":"https:\/\/acampbell.uk\/wp\/wp-json\/wp\/v2\/posts\/454\/revisions\/921"}],"wp:attachment":[{"href":"https:\/\/acampbell.uk\/wp\/wp-json\/wp\/v2\/media?parent=454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/acampbell.uk\/wp\/wp-json\/wp\/v2\/categories?post=454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/acampbell.uk\/wp\/wp-json\/wp\/v2\/tags?post=454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}