<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>sglavoie.com – Tag: Vim</title><link>https://www.sglavoie.com/tags/vim/</link><description>Posts and writings by Sébastien Lavoie. Customization setups and articles on productivity for developers who like minimalism.</description><language>en</language><atom:link href="https://www.sglavoie.com/tags/vim/feed.xml" rel="self" type="application/rss+xml"/><lastBuildDate>Sat, 13 Jul 2019 13:10:00 -0500</lastBuildDate><item><title>Black: A Python Formatter to Brighten Your Workflow</title><link>https://www.sglavoie.com/posts/black-a-python-formatter-to-brighten-your-workflow/</link><description>Meet Black, a superb Python code formatter that will automatically reformat your code in accordance to PEP-8 standards.</description><content:encoded>&lt;hr&gt;
&lt;h2 id="what-is-black"&gt;What is Black?&lt;/h2&gt;
&lt;p&gt;From its &lt;a href="https://github.com/python/black"&gt;GitHub repository&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
 &lt;p&gt;Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from pycodestyle nagging about formatting. You will save time and mental energy for more important matters.&lt;/p&gt;

&lt;/blockquote&gt;&lt;p&gt;&lt;strong&gt;Black&lt;/strong&gt; will take less than ideal code and will automatically reformat it according to the &lt;a href="https://www.python.org/dev/peps/pep-0008/"&gt;PEP-8 style guide&lt;/a&gt;. It will take care of many things, including the following (taken in that order from &lt;code&gt;README.md&lt;/code&gt; in &lt;strong&gt;Black&lt;/strong&gt;&amp;rsquo;s repo):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Wrapping lines properly by shortening as much as possible single statements;&lt;/li&gt;
&lt;li&gt;Break long lines;&lt;/li&gt;
&lt;li&gt;Remove superfluous empty lines;&lt;/li&gt;
&lt;li&gt;Take care of adding trailing commas where necessary;&lt;/li&gt;
&lt;li&gt;Convert single quotes (&lt;code&gt;'&lt;/code&gt;) to double quotes (&lt;code&gt;&amp;quot;&lt;/code&gt;);&lt;/li&gt;
&lt;li&gt;Convert numeric literals to lowercase (&lt;code&gt;0XAB&lt;/code&gt; to &lt;code&gt;0xAB&lt;/code&gt;);&lt;/li&gt;
&lt;li&gt;Superfluous parentheses are removed;&lt;/li&gt;
&lt;li&gt;Split call chains on different lines;&lt;/li&gt;
&lt;li&gt;Works from the terminal and support many code editor integrations (Emacs, Vim, VS Code, Sublime, etc.).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now that it&amp;rsquo;s clear &lt;em&gt;why&lt;/em&gt; it can be a good idea to use it, let&amp;rsquo;s see how it works with Vim and the terminal.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="how-to-use-it"&gt;How to use it?&lt;/h2&gt;
&lt;p&gt;First, we need to install it using Python 3.6.0+:&lt;/p&gt;
&lt;div class="code-block" data-prompted&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;bash&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="code-block__prompt"&gt;$ &lt;/span&gt;pip install black&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;That&amp;rsquo;s it!&lt;/p&gt;
&lt;h3 id="use-it-from-the-terminal"&gt;Use it from the terminal&lt;/h3&gt;
&lt;p&gt;In its simplest invocation, we can use &lt;strong&gt;Black&lt;/strong&gt; by specifying a file or a directory by typing:&lt;/p&gt;
&lt;div class="code-block" data-prompted&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;bash&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="code-block__prompt"&gt;$ &lt;/span&gt;black path_to_file_or_directory&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;It doesn&amp;rsquo;t come with many options as its goal is to automatically format code consistently, but you can find out more about this tool in the following way:&lt;/p&gt;
&lt;div class="code-block" data-prompted&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;bash&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="code-block__prompt"&gt;$ &lt;/span&gt;black --help&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id="use-it-with-vim"&gt;Use it with Vim&lt;/h3&gt;
&lt;p&gt;Using &lt;strong&gt;Black&lt;/strong&gt; as part of your workflow in a code editor is where I believe it really shines, because you can see almost in real-time when you make a formatting mistake, which will help down the road in committing less sins.&lt;/p&gt;
&lt;p&gt;Integrating &lt;strong&gt;Black&lt;/strong&gt; with Vim or Neovim is quick and painless, adding a simple line in your &lt;code&gt;.vimrc&lt;/code&gt; or &lt;code&gt;init.vim&lt;/code&gt; file. You can also proceed to do a manual installation without a plugin manager as explained in the GitHub repository.&lt;/p&gt;
&lt;p&gt;With &lt;a href="https://github.com/junegunn/vim-plug"&gt;vim-plug&lt;/a&gt;:&lt;/p&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;vim&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;Plug&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;python/black&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;With &lt;a href="https://github.com/VundleVim/Vundle.vim"&gt;Vundle&lt;/a&gt;:&lt;/p&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;vim&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;Plugin&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;python/black&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Once the plugin is installed, it may well be convenient to automatically format Python files when saving the buffer, which can be accomplished by adding the following line to the configuration file:&lt;/p&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;vim&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;autocmd&lt;/span&gt; &lt;span class="nx"&gt;BufWritePre&lt;/span&gt; *.&lt;span class="nx"&gt;py&lt;/span&gt; &lt;span class="k"&gt;execute&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;:Black&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;By default, &lt;strong&gt;Black&lt;/strong&gt; works surprisingly well on its own. I only went ahead and changed the default line length from 88 to 79 characters by also adding this line:&lt;/p&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;vim&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;g&lt;/span&gt;:&lt;span class="nx"&gt;black_linelength&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;79&lt;/span&gt; &lt;span class="c"&gt;&amp;#34; default is 88&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Finally, it&amp;rsquo;s worth noting you can update &lt;strong&gt;Black&lt;/strong&gt; at any point from the terminal with &lt;code&gt;pip&lt;/code&gt; and you can also do it directly from within Vim/Neovim with this command:&lt;/p&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;vim&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;BlackUpgrade&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Vim will then output something along those lines:&lt;/p&gt;
&lt;blockquote&gt;
 &lt;p&gt;Upgrading Black with pip&amp;hellip;&lt;/p&gt;

&lt;/blockquote&gt;&lt;blockquote&gt;
 &lt;p&gt;DONE! You are all set, thanks for waiting&lt;/p&gt;

&lt;/blockquote&gt;&lt;h2 id="any-example"&gt;Any example?&lt;/h2&gt;
&lt;p&gt;Taking a random Python 3.6+ code sample, we could originally have something like this (hopefully not):&lt;/p&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;python&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data_sources&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# Retrieve a list of all matching log files in `source`&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;log_files&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;LOG_NAME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;*&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;log_files&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="p"&gt;]:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s1"&gt;There is no log file to delete in &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;.&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Log files in &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;:&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;log_file&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;log_files&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ARGUMENTS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remind&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;REMINDER_IS_SET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;log_file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s1"&gt;Do you want to delete log files &amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;for this source? (y/n) &amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_says_yes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;log_file&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;log_files&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log_file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s1"&gt;&amp;#39;Log files deleted.&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;Exiting script...&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Running &lt;strong&gt;Black&lt;/strong&gt;, we will get something that&amp;rsquo;s quite a bit more palatable:&lt;/p&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;python&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data_sources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# Retrieve a list of all matching log files in `source`&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;log_files&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;LOG_NAME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;*&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;log_files&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;[]:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;There is no log file to delete in &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Log files in &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;:&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;log_file&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;log_files&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ARGUMENTS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;REMINDER_IS_SET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log_file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;Do you want to delete log files &amp;#34;&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;for this source? (y/n) &amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;user_says_yes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;log_file&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;log_files&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log_file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Log files deleted.&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Exiting script...&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;hr&gt;
&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;I think the results speak for themselves: enforcing a style with a tool like &lt;strong&gt;Black&lt;/strong&gt; is definitely useful to avoid arguments about conflicting coding styles. It lets you focus on what matters instead: being productive while providing value to the world.&lt;/p&gt;</content:encoded><dc:creator>Sébastien Lavoie</dc:creator><pubDate>Sat, 13 Jul 2019 13:10:00 -0500</pubDate><guid isPermaLink="false">https://www.sglavoie.com/posts/black-a-python-formatter-to-brighten-your-workflow/</guid><category>workflow</category><category>neovim</category><category>plugin</category><category>productivity</category><category>python</category><category>terminal</category><category>vim</category></item><item><title>Tag Navigation in Vim</title><link>https://www.sglavoie.com/posts/tag-navigation-in-vim/</link><description>A quick introduction to tag navigation in Vim/Neovim.</description><content:encoded>&lt;hr&gt;
&lt;h2 id="navigate-inside-the-current-buffer"&gt;Navigate inside the current buffer&lt;/h2&gt;
&lt;p&gt;There is a command &lt;code&gt;gd&lt;/code&gt; that stands for &lt;strong&gt;Goto local Declaration&lt;/strong&gt;. It is quite useful when looking for a variable inside the current buffer as it allows to jump to where it is declared when the variable is under the cursor. Using that command, you can also find where a function is declared and it will find the first occurrence in the current function. If looking for the first occurrence in the buffer, &lt;code&gt;gD&lt;/code&gt; (&lt;strong&gt;Goto global Declaration&lt;/strong&gt;) will do the trick. You can jump back and forth to where you were with the commands &lt;code&gt;Ctrl + O&lt;/code&gt; (older position) and &lt;code&gt;Ctrl + I&lt;/code&gt; (newer position) in normal mode.&lt;/p&gt;
&lt;h2 id="navigate-inside-all-buffers-within-the-current-project"&gt;Navigate inside all buffers within the current project&lt;/h2&gt;
&lt;p&gt;To be able to jump between buffers and go back to the origin of a declaration when it is imported in the current module, generating tags comes in very handy as it allows you to use the command &lt;code&gt;Ctrl + ]&lt;/code&gt; to jump to a tag, just like when using the help pages in &lt;strong&gt;Vim&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;To make this work, we can conveniently use &lt;code&gt;ctags&lt;/code&gt;. First, we need to make sure it&amp;rsquo;s installed on the system as follow:&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id="debianubuntu"&gt;Debian/Ubuntu&lt;/h3&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;bash&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo apt-get install ctags&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;bash&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo apt-get install exuberant-ctags&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id="os-x"&gt;OS X&lt;/h3&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;bash&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;brew install ctags&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;hr&gt;
&lt;p&gt;You can put the following command in your configuration file to be able to generate the necessary tags inside &lt;strong&gt;Vim&lt;/strong&gt; by typing &lt;code&gt;MakeTags&lt;/code&gt; in command mode:&lt;/p&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;vim&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;command&lt;/span&gt;&lt;span class="p"&gt;!&lt;/span&gt; &lt;span class="nx"&gt;MakeTags&lt;/span&gt; &lt;span class="p"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;ctags&lt;/span&gt; &lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;R&lt;/span&gt; .&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This will make it easy to remember how to do it. After that, open an existing project in its root directory and use this newly created &lt;code&gt;MakeTags&lt;/code&gt; command to generate the tags. This will create a file named &lt;code&gt;tags&lt;/code&gt; in the current working directory*. Now, you will be able to open any file inside your project and jump to all the available declarations with &lt;code&gt;Ctrl + ]&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;* &lt;sub&gt;Note: This will create tags recursively from the &lt;em&gt;current working directory&lt;/em&gt;, &lt;strong&gt;not&lt;/strong&gt; from the path matching the current buffer.&lt;/sub&gt;&lt;/p&gt;
&lt;p&gt;If you go to a tag that leads you a few declarations away in one file or another, you can come back with &lt;code&gt;Ctrl + T&lt;/code&gt;. Here is a clear explanation from Vim&amp;rsquo;s help:&lt;/p&gt;
&lt;div class="code-block code-block--wrap"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;pre tabindex="0"&gt;&lt;code&gt;The most obvious way to use this is while browsing through the call graph of
a program. Consider the following call graph:

	main ---&amp;gt; FuncA ---&amp;gt; FuncC
	 ---&amp;gt; FuncB

(Explanation: main calls FuncA and FuncB; FuncA calls FuncC).
You can get from main to FuncA by using CTRL-] on the call to FuncA. Then
you can CTRL-] to get to FuncC. If you now want to go back to main you can
use CTRL-T twice. Then you can CTRL-] to FuncB.&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;To keep those tags useful when you update your project, you can map a sequence that saves the buffer you are working on and then regenerates the tags automatically. Here is an example:&lt;/p&gt;
&lt;div class="code-block"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__lang"&gt;vim&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;nnoremap&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;leader&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;W&lt;/span&gt; :&lt;span class="nx"&gt;w&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;CR&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;:&lt;span class="nx"&gt;MakeTags&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;CR&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;:&lt;span class="nx"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;ctags have been updated.&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;CR&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;And on this note, we&amp;rsquo;re ready to conquer the world.&lt;/p&gt;</content:encoded><dc:creator>Sébastien Lavoie</dc:creator><pubDate>Fri, 19 Apr 2019 17:52:00 -0500</pubDate><guid isPermaLink="false">https://www.sglavoie.com/posts/tag-navigation-in-vim/</guid><category>tips-and-tricks</category><category>productivity</category><category>vim</category></item><item><title>Using Vimwiki for Note-Taking</title><link>https://www.sglavoie.com/posts/using-vimwiki-for-note-taking/</link><description>This short article explains why Vimwiki felt like the right solution to organize my notes.</description><content:encoded>&lt;hr&gt;
&lt;h2 id="what-is-vimwiki"&gt;What is Vimwiki?&lt;/h2&gt;
&lt;p&gt;From the &lt;a href="https://vimwiki.github.io/"&gt;official website&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
 &lt;p&gt;Vimwiki is a personal wiki for Vim – interlinked, plain text files
written in a markup language.&lt;/p&gt;

&lt;/blockquote&gt;&lt;p&gt;As this relies upon Vim&amp;rsquo;s power to write content in a simple format,
this quickly became a viable option to organize more and more notes!&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="what-were-the-other-options-considered"&gt;What were the other options considered?&lt;/h2&gt;
&lt;p&gt;I have used various approaches in the past for different purposes and
reasons, including &lt;em&gt;Evernote&lt;/em&gt;, &lt;em&gt;Simplenote&lt;/em&gt;, &lt;em&gt;Microsoft OneNote&lt;/em&gt;,
&lt;em&gt;Google Docs&lt;/em&gt;, &lt;em&gt;Boostnote&lt;/em&gt;, &lt;em&gt;Freeplane&lt;/em&gt;/&lt;em&gt;FreeMind&lt;/em&gt; (mind-mapping),
&lt;em&gt;Workflowy&lt;/em&gt; and even plain &lt;code&gt;.txt&lt;/code&gt; files. Each has its pros and cons, but
I then decided to limit my options based on the following self-imposed
requirements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It has to be &lt;strong&gt;available on Linux&lt;/strong&gt;. Right from the start, this would
disqualify many applications such as &lt;em&gt;Notational Velocity&lt;/em&gt;, &lt;em&gt;Bear&lt;/em&gt;,
&lt;em&gt;Quiver&lt;/em&gt;, &lt;em&gt;Paper&lt;/em&gt;, &lt;em&gt;Ulysses&lt;/em&gt; and &lt;em&gt;Squid&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;It has to be &lt;strong&gt;open source&lt;/strong&gt; as this is a philosophy that I strongly
embrace. Plus, having the ability to freely modify it and contribute to
the project is an important additional bonus. Adiós &lt;em&gt;Evernote&lt;/em&gt;, &lt;em&gt;Google
Docs&lt;/em&gt;, &lt;em&gt;Dropbox Paper&lt;/em&gt;, &lt;em&gt;Microsoft OneNote&lt;/em&gt;, &lt;em&gt;Workflowy&lt;/em&gt; and &lt;em&gt;Quip&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;It has to be &lt;strong&gt;fast to use&lt;/strong&gt; and it has to make it possible
to &lt;strong&gt;express oneself in more than one way&lt;/strong&gt;. Say goodbye to
&lt;em&gt;&lt;a href="https://www.freeplane.org"&gt;Freeplane&lt;/a&gt;&lt;/em&gt; (otherwise great for
general brainstorming!) and &lt;em&gt;FreeMind&lt;/em&gt; (which has been abandoned
by its own developers): both are relatively slow on an old machine
because they use Java and it is quite a stretch to use them for
something other than mind maps. In that same category would disappear
&lt;em&gt;&lt;a href="https://www.draw.io/"&gt;draw.io&lt;/a&gt;&lt;/em&gt;, which is fantastic for making
flowcharts and diagrams!&lt;/li&gt;
&lt;li&gt;It has to be versatile enough to handle features such as &lt;strong&gt;including
images, links and attached files&lt;/strong&gt; and have a way to perform &lt;strong&gt;search
and replace&lt;/strong&gt;. Ciao &lt;em&gt;&lt;a href="https://simplenote.com/"&gt;Simplenote&lt;/a&gt;&lt;/em&gt; which
is, well, simple. Even though it doesn&amp;rsquo;t fit the bill in this case,
it remains a great option as it can synchronize your notes with many
different devices (iOS, macOS, Android, Windows and Linux). It has
a feature that allows you to move a slider which acts as a timeline
and shows you a different version of your note since its creation
with the actual date and time down to the minute for each &lt;em&gt;restore
point&lt;/em&gt;. You can also use tags and Markdown and it has options to
share and collaborate with others. Highly recommended!&lt;/li&gt;
&lt;li&gt;It should have a hefty user base to back it up. This would exclude
text editor plugins such as &lt;code&gt;atom-notes&lt;/code&gt; for &lt;em&gt;Atom&lt;/em&gt; or &lt;code&gt;VSNotes&lt;/code&gt; for &lt;em&gt;VS
Code&lt;/em&gt;, which also lack features for accomplishing all of the above.&lt;/li&gt;
&lt;li&gt;On top of everything else, it has to be &lt;strong&gt;available offline&lt;/strong&gt;, in a
&lt;strong&gt;portable and readable format&lt;/strong&gt;. Now, after discarding most options, we
are left with &lt;em&gt;Boostnote&lt;/em&gt; which uses CoffeeScript-Object-Notation and
&lt;em&gt;Vimwiki&lt;/em&gt; which has its own Wiki syntax that&amp;rsquo;s similar in many ways to
Markdown*. Those are the strongest contenders that I could think of but
of course, if you would like to share your recommendations, please do so
in the comments below!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;* &lt;sub&gt;I somehow discredited
&lt;strong&gt;&lt;a href="https://www.gnu.org/software/emacs"&gt;Emacs&lt;/a&gt;&lt;/strong&gt; simply because I started
to learn Vim first and since I&amp;rsquo;m still far from understanding all of
its features, I had to postpone the discovery of Emacs.&lt;/sub&gt;&lt;/p&gt;
&lt;h3 id="one-feature-rich-alternative-to-vimwiki"&gt;One feature-rich alternative to Vimwiki&lt;/h3&gt;
&lt;p&gt;After settling down on Vimwiki, I later found out about &lt;a
href="https://joplin.cozic.net"&gt;Joplin&lt;/a&gt;, which comes with many great
features and characteristics such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Free &amp;amp; Open Source&lt;/li&gt;
&lt;li&gt;Manages notes and todo lists&lt;/li&gt;
&lt;li&gt;Search across all notes/todos&lt;/li&gt;
&lt;li&gt;Import/Export from/to various formats, including Markdown and even
imports from Evernote&lt;/li&gt;
&lt;li&gt;Support for attachments&lt;/li&gt;
&lt;li&gt;Tags&lt;/li&gt;
&lt;li&gt;Synchronization with multiple providers such as Dropbox, Nextcloud,
OneDrive and even your own private cloud&lt;/li&gt;
&lt;li&gt;Available for Windows, Linux, macOS, Android and iOS&lt;/li&gt;
&lt;li&gt;Web Clipper integration&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This application left me a great first impression to say the least and I
will make sure to stay up to date on its active development, which you
can &lt;a href="https://github.com/laurent22/joplin"&gt;follow on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="why-did-vimwiki-win-in-the-end"&gt;Why did Vimwiki win in the end?&lt;/h2&gt;
&lt;h3 id="in-short"&gt;In short&lt;/h3&gt;
&lt;blockquote&gt;
 &lt;p&gt;The modal nature of Vim makes it very hard to enjoy any other text
editor once you get used to it. The learning curve is quite considerable
and nearly infinite, but this is also why I think it is worth investing
more time to master it as it has proven to be an everlasting piece of
trusty software.&lt;/p&gt;

&lt;/blockquote&gt;&lt;blockquote&gt;
 &lt;p&gt;There is a feature in Boostnote to set the Editor Keymap to &lt;code&gt;vim&lt;/code&gt; so
that you can edit text in a very similar way, but then you miss out on
Vim&amp;rsquo;s &lt;code&gt;Command mode&lt;/code&gt; which adds tremendous extensibility and the ability
to create any mappings you wish on the fly.&lt;/p&gt;

&lt;/blockquote&gt;&lt;hr&gt;
&lt;h4 id="expanded-edition"&gt;Expanded edition&lt;/h4&gt;
&lt;p&gt;Boostnote comes with nice features such as Tags, the ability to set
multiple storage locations for notes, a &lt;code&gt;Preferences&lt;/code&gt; panel to adjust
many options, a feature to add code snippets, real-time preview of
Markdown being edited, etc. Make no mistake: this is a great program.
But there are many Vim features that are hard or impossible to replicate
and everything that you can do in Boostnote can be done in Vim also
(ctags, emmet syntax, plugins for Markdown, etc.).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For starters, the terminal integration is obviously unmatched. In
Vim, &lt;code&gt;CTRL+Z&lt;/code&gt; will &lt;em&gt;stop&lt;/em&gt; Vim and gives you access to the terminal to
do whatever you want to do. From that point, you can simply switch back
to Vim by issuing the command &lt;code&gt;fg&lt;/code&gt;. The terminal integration goes even
further: you can have full access to the terminal inside Vim buffers
since Vim 8.1 and that is a feature that has been available in Neovim
for even longer.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Even though &lt;code&gt;vim&lt;/code&gt; mode can be enabled to edit text, you have to use
the mouse to get many tasks done and the editing window can loose the
focus. On the other hand, Vim is just one single window by default that
you can split however you want, including adding tabs if your heart
tells you to.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You have to open your notes with Boostnote if you want them to be
fully readable out of the box. Vimwiki does almost no processing with
the content of the files so that it is very easy to open them with any
other text editor. On a related note, it is much easier to export many
notes at the same time with Vimwiki. Boostnote does have a few options
to export individual notes (&lt;code&gt;.md&lt;/code&gt;, &lt;code&gt;.txt&lt;/code&gt;, &lt;code&gt;.html&lt;/code&gt; and print), but it is
not as user-friendly with many notes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Vimwiki makes it easy to link notes together and navigate between
them, even within subfolders: highlight text, press &lt;code&gt;Enter&lt;/code&gt; to create a
link and open a new note, write your note and press &lt;code&gt;Backspace&lt;/code&gt; to go
back to where you created the link. That&amp;rsquo;s quick and easy!&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;In the end, it is a matter of taste as those programs are indeed very
distinct. Boostnote has a polished interface, is much easier to use and
has many settings easily changed. Vim/Neovim, on the contrary, requires
a lot of initial effort both to understand and to set up according
to your needs, but it does deliver a good dose of productivity&amp;hellip;
Eventually!&lt;/p&gt;
&lt;p&gt;An honorable mention goes to Simplenote, which is a joy to use with
mobile devices and allows for quick synchronization between different
devices across all the supported platforms.&lt;/p&gt;
&lt;p&gt;Where things really get in favor of Vim, you could mention the extensive
help system (command &lt;code&gt;:help&lt;/code&gt;), the use of macros, words and lines
completion, the dot (&lt;code&gt;.&lt;/code&gt;) command, the many registers at your disposal
for different tasks, the impressive amount of plugins available, the
ways in which you can configure mappings, functions&amp;hellip; But that&amp;rsquo;s for a
whole new story!&lt;/p&gt;</content:encoded><dc:creator>Sébastien Lavoie</dc:creator><pubDate>Mon, 03 Dec 2018 13:26:00 -0600</pubDate><guid isPermaLink="false">https://www.sglavoie.com/posts/using-vimwiki-for-note-taking/</guid><category>workflow</category><category>neovim</category><category>note-taking</category><category>productivity</category><category>vim</category><category>vimwiki</category></item><item><title>Tmux Integration with Vim/Neovim — First Steps</title><link>https://www.sglavoie.com/posts/tmux-integration-with-vim-neovim-first-steps/</link><description>This is a short introduction that shows a possible workflow with tmux and Vim/Neovim.</description><content:encoded>&lt;hr&gt;
&lt;h2 id="tmux-integration"&gt;tmux integration&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/tmux/tmux"&gt;tmux&lt;/a&gt; offers many advantages in the
context of remote access to another machine, but it also shines on a
local setup! Here is how I currently like to set it up.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id="configuration-file"&gt;Configuration file&lt;/h3&gt;
&lt;div class="code-block code-block--titled"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__title"&gt;~/.tmux.conf&lt;/span&gt;
 &lt;span class="code-block__lang"&gt;bash&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight" title="~/.tmux.conf"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# split panes using | and -&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;bind&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; split-window -h
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;bind&lt;/span&gt; - split-window -v
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;unbind &lt;span class="s1"&gt;&amp;#39;&amp;#34;&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;unbind %
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# switch panes using Alt-arrow without prefix&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;bind&lt;/span&gt; -n M-Left &lt;span class="k"&gt;select&lt;/span&gt;-pane -L
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;bind&lt;/span&gt; -n M-Right &lt;span class="k"&gt;select&lt;/span&gt;-pane -R
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;bind&lt;/span&gt; -n M-Up &lt;span class="k"&gt;select&lt;/span&gt;-pane -U
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;bind&lt;/span&gt; -n M-Down &lt;span class="k"&gt;select&lt;/span&gt;-pane -D
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Enable mouse mode (tmux 2.1 and above)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;set&lt;/span&gt; -g mouse on
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;source-file &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/.tmux-themepack/blue.tmuxtheme&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This is all very self-explanatory. &lt;a href="https://github.com/jimeh/tmux-themepack"&gt;Many themes can be found
here&lt;/a&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id="automating-the-launch-of-a-default-session"&gt;Automating the launch of a default session&lt;/h3&gt;
&lt;p&gt;This is a small Bash script that I like to have for automatic set up
of a development environment with tmux and Vim/Neovim. As my current
workflow, I enjoy the following:&lt;/p&gt;
&lt;div class="code-block code-block--titled"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__title"&gt;~/.tmux_default_session.sh&lt;/span&gt;
 &lt;span class="code-block__lang"&gt;bash&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight" title="~/.tmux_default_session.sh"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;#!bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# var for session name (to avoid repeated occurences)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;sn&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dev
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux new-session -s &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$sn&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt; -d
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Create 3 windows&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux new-window -t &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$sn&lt;/span&gt;&lt;span class="s2"&gt;:0&amp;#34;&lt;/span&gt; -n &lt;span class="s2"&gt;&amp;#34;nvim&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux new-window -t &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$sn&lt;/span&gt;&lt;span class="s2"&gt;:9&amp;#34;&lt;/span&gt; -n &lt;span class="s2"&gt;&amp;#34;python&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux new-window -t &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$sn&lt;/span&gt;&lt;span class="s2"&gt;:8&amp;#34;&lt;/span&gt; -n &lt;span class="s2"&gt;&amp;#34;terminal&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Split terminal window vertically, then split the right pane&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# horizontally, then switch to the left pane (identified by `FOCUS IS&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# HERE`).&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# _________________&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# |&amp;gt;_ |&amp;gt;_ |&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# | | |&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# | FOCUS |-------|&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# | IS |&amp;gt;_ |&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# | HERE | |&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# -----------------&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux split-window -h
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux split-window -v
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux &lt;span class="k"&gt;select&lt;/span&gt;-pane -L
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Set up Neovim ready to open files&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux send-keys -t &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$sn&lt;/span&gt;&lt;span class="s2"&gt;:0&amp;#34;&lt;/span&gt; C-z &lt;span class="s1"&gt;&amp;#39;nvim .&amp;#39;&lt;/span&gt; Enter
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Set up alias for IPython and clear the screen when entering IPython&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux send-keys -t &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$sn&lt;/span&gt;&lt;span class="s2"&gt;:9&amp;#34;&lt;/span&gt; C-z &lt;span class="s1"&gt;&amp;#39;ipython&amp;#39;&lt;/span&gt; Enter
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux send-keys -t &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$sn&lt;/span&gt;&lt;span class="s2"&gt;:9&amp;#34;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;clear&amp;#39;&lt;/span&gt; Enter
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Select window #0 and attach to the session&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux &lt;span class="k"&gt;select&lt;/span&gt;-window -t &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$sn&lt;/span&gt;&lt;span class="s2"&gt;:0&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tmux -2 attach-session -t &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$sn&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;hr&gt;
&lt;h3 id="aliases-to-make-use-of"&gt;Aliases to make use of&lt;/h3&gt;
&lt;p&gt;I add the following aliases in &lt;code&gt;~/.bash_aliases&lt;/code&gt; to automate a chunk of
the workflow:&lt;/p&gt;
&lt;div class="code-block code-block--titled"&gt;
 &lt;div class="code-block__bar" data-pagefind-ignore&gt;
 &lt;span class="code-block__title"&gt;~/.bash_aliases&lt;/span&gt;
 &lt;span class="code-block__lang"&gt;bash&lt;/span&gt;
 &lt;button class="code-block__wrap" type="button" aria-pressed="false" hidden&gt;Wrap&lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="highlight" title="~/.bash_aliases"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# This will launch tmux with the desired configuration&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;dev&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;bash ~/.tmux_default_session.sh&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# This will kill the tmux server if the need arises. By detaching from&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# the tmux session, you simply run this command and can reattach easily&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# to the default session configuration on another project.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;kdev&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;pkill tmux&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# If the session has been detached but the tmux server is still running,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# I use the following alias to quickly reattach to the default session&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# named `dev` in that example.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;adev&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;tmux attach-session -t dev&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;hr&gt;
&lt;h3 id="tmux-demo"&gt;tmux demo&lt;/h3&gt;
&lt;p&gt;(click to open image)
&lt;a href="https://www.sglavoie.com/images/posts/0001_tmux-integration-with-vim/tmux-demo.gif"&gt;&lt;img src="https://www.sglavoie.com/images/posts/0001_tmux-integration-with-vim/tmux-demo.gif" alt="Animated tmux and Vim integration demo" class="max-size-img-post" width="1366" height="768" loading="lazy" decoding="async"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;The content of this post can be found on
&lt;a href="https://github.com/sglavoie/better-vim-experience#tmux-integration"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;</content:encoded><dc:creator>Sébastien Lavoie</dc:creator><pubDate>Mon, 19 Nov 2018 20:31:00 -0600</pubDate><guid isPermaLink="false">https://www.sglavoie.com/posts/tmux-integration-with-vim-neovim-first-steps/</guid><category>workflow</category><category>neovim</category><category>terminal</category><category>tmux</category><category>vim</category></item></channel></rss>