{"id":8003,"date":"2021-01-04T17:24:42","date_gmt":"2021-01-04T16:24:42","guid":{"rendered":"https:\/\/monodes.com\/predaelli\/?p=8003"},"modified":"2021-01-04T17:24:42","modified_gmt":"2021-01-04T16:24:42","slug":"5-lines-i-put-in-a-blank-vimrc-sword-and-signals","status":"publish","type":"post","link":"https:\/\/monodes.com\/predaelli\/2021\/01\/04\/5-lines-i-put-in-a-blank-vimrc-sword-and-signals\/","title":{"rendered":"5 lines I put in a blank .vimrc | Sword and Signals"},"content":{"rendered":"<blockquote><p>TL;DR To make a default Vim installation more useful, type the following 5 lines into its .vimrc file:<\/p>\n<p><code class=\"\" data-line=\"\">set hlsearch    &quot; highlight all search results<\/p>\n<p><\/code><code class=\"\" data-line=\"\">set ignorecase  &quot; do case insensitive search<br \/>\nset incsearch   &quot; show incremental search results as you type<\/p>\n<p>set number      &quot; display line number<\/p>\n<p>set noswapfile  &quot; disable swap file<\/code><\/p><\/blockquote>\n<p>Source: <em><a href=\"https:\/\/swordandsignals.com\/2020\/12\/13\/5-lines-in-vimrc.html\">5 lines I put in a blank .vimrc | Sword and Signals<\/a><\/em><\/p>\n<p><!--more--><\/p>\n<blockquote><p>To make a default Vim installation more useful, type the following 5 lines into its <code class=\"\" data-line=\"\">.vimrc<\/code> file:<\/p>\n<div class=\"language-plaintext highlighter-rouge\">\n<div class=\"highlight\">\n<pre class=\"highlight\" data-lang=\"plaintext\"><code class=\"\" data-line=\"\">set hls\nset ic\nset is\nset nu\nset noswf\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>Or if you prefer, copy and paste the spelled out and annotated version:<\/p>\n<div class=\"language-plaintext highlighter-rouge\">\n<div class=\"highlight\">\n<pre class=\"highlight\" data-lang=\"plaintext\"><code class=\"\" data-line=\"\">set hlsearch    &quot; highlight all search results\nset ignorecase  &quot; do case insensitive search \nset incsearch   &quot; show incremental search results as you type\nset number      &quot; display line number\nset noswapfile  &quot; disable swap file\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>For what it\u2019s worth, the acronym for the 5 lines is <code class=\"\" data-line=\"\">HIINN<\/code>.<\/p>\n<p><strong>Edit<\/strong>: <a href=\"https:\/\/news.ycombinator.com\/item?id=25410751\" target=\"_blank\" rel=\"noopener\">Multiple people on HN<\/a> <a href=\"https:\/\/news.ycombinator.com\/item?id=25410742\" target=\"_blank\" rel=\"noopener\">have pointed out<\/a> that the 5 lines can be combined into a single line like below. I didn\u2019t know about this capability, but will definitely start doing this from now on:<\/p>\n<div class=\"language-plaintext highlighter-rouge\">\n<div class=\"highlight\">\n<pre class=\"highlight\" data-lang=\"plaintext\"><code class=\"\" data-line=\"\">set hls ic is nu noswf\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>Also, as mentioned below, this is for temporary environments where you read more than you edit. For your local set up, it\u2019s better to take the time to properly maintain the config file and install plugins as needed.<\/p>\n<h2 id=\"motivation\">Motivation<\/h2>\n<p><a href=\"https:\/\/www.vim.org\/\" target=\"_blank\" rel=\"noopener\">Vim<\/a> is a powerful text editor for Unix\/Linux, and I use it frequently to view and edit files. Unfortunately, Vim\u2019s default configurations lack several important usability features compared to popular alternative text editors, such as <a href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\" rel=\"noopener\">VSCode<\/a>.<\/p>\n<p>The undesirable defaults are not an issue on my own computer, as I can take the time to configure them. However, often I\u2019d find myself debugging or reading logs on near-fresh Linux installations (eg. virtual machines spun up to do integration testing), where Vim had not yet been configured.<\/p>\n<p>So over time, I distilled the text editor features that I needed the most, and came up with the list above. To set it up, I would run <code class=\"\" data-line=\"\">vim ~\/.vimrc<\/code>, manually enter those 5 lines in whichever order that I remembered them, then quit and restart Vim to pick up the new configurations.<\/p>\n<h2 id=\"discussion\">Discussion<\/h2>\n<p>The first 4 lines are straightforward &#8211; most popular modern text editors already come with all of them out of the box. The last one could be controversial, since <a href=\"http:\/\/vimdoc.sourceforge.net\/htmldoc\/recover.html#swap-file\" target=\"_blank\" rel=\"noopener\">swap file<\/a> is designed to help users recover work. In practice though, I find it to be more in the way, due to the additional dialogue that pops up when opening a file that has an existing swap file. The recovery feature itself is also not useful to me, as I more often read logs rather than make edits in those cases.<\/p>\n<p>The next time you find yourself in a similar situation, I recommend you to also try putting those 5 lines into the <code class=\"\" data-line=\"\">.vimrc<\/code>. It could make your Vim experience just a bit bet<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">TL;DR To make a default Vim installation more useful, type the following 5 lines into its .vimrc file: set hlsearch &quot; highlight all search results set ignorecase &quot; do case insensitive search set incsearch &quot; show incremental search results as you type set number &quot; display line number set noswapfile &quot; disable swap file Source:&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/monodes.com\/predaelli\/2021\/01\/04\/5-lines-i-put-in-a-blank-vimrc-sword-and-signals\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[72],"tags":[55],"class_list":["post-8003","post","type-post","status-publish","format-standard","hentry","category-documentations","tag-vim"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6daft-255","jetpack-related-posts":[{"id":10992,"url":"https:\/\/monodes.com\/predaelli\/2023\/12\/05\/search-and-replace-in-multiple-files-using-vim\/","url_meta":{"origin":8003,"position":0},"title":"Search and replace in multiple files using vim","author":"Paolo Redaelli","date":"2023-12-05","format":false,"excerpt":"Search and replace in multiple files using vim - (source Stack Overflow) It is as simple as Use: :set aw :argdo %s\/happy999\/happy111\/g The first line sets auto-write mode, so when you switch between files, vim will write the file if it has changed. The second line does your global search\u2026","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":907,"url":"https:\/\/monodes.com\/predaelli\/2016\/01\/18\/907\/","url_meta":{"origin":8003,"position":1},"title":"Interesting this Setting up Vim\u2026","author":"Paolo Redaelli","date":"2016-01-18","format":"link","excerpt":"Interesting this Setting up Vim for JavaScript development","rel":"","context":"In &quot;vim&quot;","block_context":{"text":"vim","link":"https:\/\/monodes.com\/predaelli\/category\/vim\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10923,"url":"https:\/\/monodes.com\/predaelli\/2023\/10\/24\/5-must-have-vim-plugins-that-will-change-your-workflow\/","url_meta":{"origin":8003,"position":2},"title":"5 Must-Have Vim Plugins That Will Change Your Workflow","author":"Paolo Redaelli","date":"2023-10-24","format":false,"excerpt":"5 Must-Have Vim Plugins That Will Change Your Workflow. In my case Syntastic: a syntax checking plugin for Vim which runs files through external syntax checkers and displays resulting errors. Fugitive: a Git wrapper for Vim that is self-described as \"so awesome, it should be illegal.\" Emmet: an extremely useful\u2026","rel":"","context":"In &quot;Tricks&quot;","block_context":{"text":"Tricks","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/tricks\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1895,"url":"https:\/\/monodes.com\/predaelli\/2016\/11\/15\/50-most-frequently-used-unix-linux-commands-with-examples\/","url_meta":{"origin":8003,"position":3},"title":"50 Most Frequently Used UNIX \/ Linux Commands (With Examples)","author":"Paolo Redaelli","date":"2016-11-15","format":false,"excerpt":"Several pearl in 50 Most Frequently Used UNIX \/ Linux Commands (With Examples) Add line number for all non-empty-lines in a file $ sed '\/.\/=' thegeekstuff.txt | sed 'N; s\/\\n\/ \/' Remove duplicate lines using awk $ awk '!($0 in array) { array[$0]; print }' temp \u00a0 Print all lines\u2026","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":501,"url":"https:\/\/monodes.com\/predaelli\/2015\/06\/29\/501\/","url_meta":{"origin":8003,"position":4},"title":"Time to install a proper\u2026","author":"Paolo Redaelli","date":"2015-06-29","format":"status","excerpt":"Time to install a proper plugin manager for my modular, infinitely-ductile Vim: Vundle, the plug-in manager for Vim http:\/\/github.com\/gmarik\/vundle","rel":"","context":"In &quot;GNU\/Linux&quot;","block_context":{"text":"GNU\/Linux","link":"https:\/\/monodes.com\/predaelli\/category\/gnulinux\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10754,"url":"https:\/\/monodes.com\/predaelli\/2023\/08\/31\/adding-parenthesis-around-highlighted-text-in-vim\/","url_meta":{"origin":8003,"position":5},"title":"Adding parenthesis around highlighted text in Vim","author":"Paolo Redaelli","date":"2023-08-31","format":false,"excerpt":"Lovely, lovely vim The command c()<Esc>P Explanation If you want to put the word under the cursor in to brackets this is viwc()<Esc>P. viw will visually select all charactrs in a word. c() will cchange the selection and drops you into insert mode, where you type the literal characters (\u2026","rel":"","context":"In &quot;vim&quot;","block_context":{"text":"vim","link":"https:\/\/monodes.com\/predaelli\/category\/vim\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/8003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/comments?post=8003"}],"version-history":[{"count":0,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/8003\/revisions"}],"wp:attachment":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/media?parent=8003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/categories?post=8003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/tags?post=8003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}