Posts

Newsticker - Emacs built-in RSS reader

I’ve been browsing Emacs’s The Info Directory (C-h i) the other day and came across a menu item called Newsticker.

Turned out is a built-in RSS reader I never heard of. I know Emacs has Gnus which I tried to use as RSS reader before but didn’t succeed. Then, as probably most of Emacs users, I moved to Elfeed which is great.

Here is how Newsticker looks like:

hermit logo

isn’t it nice? You can open it with M-x newsticker-show-news.

Abandoning Gemini

I’ve been running my own Gemini capsule (web site) on my cheap DigitalOcean droplet for a few years.

For those who doesn’t know what Gemini is: is a minimal web protocol (think of HTTP). It serves pages containing gemtext (think of HTML) which is super minimal too. No CSS. No JS.

The whole vibe of it reminds me of the old web that I actually never been part of but romanticised it in my head enough to be in love with it.

This blog has been migrated from Jekyll to Hugo

I have migrated this blog to Hugo yesterday.

It was fun journey and I spent about 5 hours doing it.

Why change

Recently I bought a relatively cheap laptop which I decided to use as my “Productivity Laptop”. I have Void-Linux installed and I only run Emacs and Firefox on it. There are more to it but that’s maybe a story for another blog post.

Long story short one of the outcomes of using that productivity laptop is my Gemini server written in Zig. When I wanted to write a blog post about it on the same laptop I found that I have to:

Gemini Server in ~150 lines of Zig

I’ve been running my Gemini capsule for a few years and also recently I got interested in Zig programming language.

Combining these two facts I came up with this Gemini Server implementation that is about 150 lines long (including comments).

What I like

Actually, the original idea was to implement it in Rust. And I started it in Rust. But after a few hours (spanned across multiple days) of writing Rust I felt like whatever I want to do is not acceptable and there is the only one correct path to do things (and Rust compiler will happily guide you).

Emacs: glasses-mode

Let’s say I have this code (TypeScript) with long camelCased variable names. typescript code with long names

I’m ok with camelCase variables especially if this is a convention for a language. But at the same time I find it a bit difficult to read compared to underscore_case style.

Meet M-x glasses-mode.

A beautiful minor mode that is there, built-in, since Emacs 21. Look what it does typescript code with long names but this type every name has underscores

Emacs: quick-calc

You probably have heard about famous emacs M-x calc. I always wanted to become a poweruser of it but never could. My needs are too simple for it, I just want to quickly add/subtract numbers.

Recently I’ve discovered built-in M-x quick-calc which is perfect for what I need. It is already bound to C-x * q.

You can quickly calculate what’s needed and the result is going to be saved to the kill-ring. You can paste the result in place if you want by prefixing the command with C-u.

Emacs: which-function-mode

The problem

I sometimes work with long functions or big org subtrees and it’s not always clear what function or org subtree I’m in right now. I wish there is a package that can show me what function I’m in.

which-function-mode

trace output

Turns out Emacs has this mode built-in so this functionality is just M-x which-function-mode away. It shows in the status line a function name I’m currently in (see [encode_terminal_code] on the screenshot above). It’s global mode so as soon as it’s enabled, you’ll see it’s working for every buffer. You can have it enabled on Emacs startup by adding (which-function-mode) to your config file.

I just started to get benefits of this mode but it’s already surprising how well it works:

sandbox.smtp.mailtrap.io port 25 isn't available anymore

I can’t connect to port 25 anymore. I noticed it in a Laravel application but the issue exists for everyone.

nc -vvv sandbox.smtp.mailtrap.io 25

just doesn’t connect.

It’s been an issue for a few weeks now.

To fix it just change the port 25 to 2525 (this one doesn’t require TLS).

Composer install - ignore php version constrains

Solution

Just run this:

composer install --ignore-platform-req=php

Issue

I often have an issue when after upgrading PHP to a newer versions I can’t do composer install anymore because one or more libraries haven’t updated their require.php section to support newer version of the language.

Moreover, even if you manage to install new versions of those libs you still may have other projects on your machine that require older version of php (my case).

Emacs: Did you know about IBuffer?

The problem

Sometimes I use C-x C-b to get list of buffers so I can clean it up a little after some time. To do it I mark some buffers with d (to delete) and then press x.

Today I wanted to filter that list of buffers to a particular project/folder and turned out I can’t.
There is no way to filter *Buffer List*.

IBuffer

If you look up for Buffer Menu in EmacsWiki you’ll find the Enhancements section which mentions IBufferMode which is built-in since Emacs 22.

Emacs find-grep-dired: Filter files based on content

Intro

We all need to search in files sometimes, right?

I usually do it using grep -ri 'search term' . in the terminal (often in vterm-mode) and then I either open the file(s) in Emacs or in any other program.

But Emacs has better solution to it.

find-grep-dired

There is M-x find-grep-dired already built-in to Emacs. If you call it from Dired buffer it will auto-complete the current folder and then you just need to enter the search term.

Weechat is a lightweight IRC client

This is more of a joke post.

Weechat is lightweight

Weechat is incredible, terminal based IRC client, that I wanted to install recently on my FreeBSD instance.

It’s lightweight.

Here is log from my pkg install weechat:

[user@server]# pkg install weechat
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 18 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        aspell: 0.60.8_1,1
        glib: 2.72.2,2
        gmp: 6.2.1
        gnutls: 3.7.6
        libedit: 3.1.20210910,1
        libiconv: 1.16
        liblz4: 1.9.3,1
        libtasn1: 4.18.0
        libunwind: 20211201_1
        lua52: 5.2.4
        nettle: 3.8
        p11-kit: 0.24.1_1
        pcre: 8.45_1
        perl5: 5.32.1_1
        ruby: 3.0.4_2,1
        tcl86: 8.6.12
        weechat: 3.5_2
        zstd: 1.5.2

Number of packages to be installed: 18

The process will require 219 MiB more space.
40 MiB to be downloaded.

Proceed with this action? [y/N]:

219 MiB - isn’t it funny? I think it is.
Slack *.dmg file for MacOS takes 168 MiB.

Emacs has built-in thread macros

Intro

Surprisingly for me I just discovered that Emacs Lisp has equivalent of Clojure’s -> and ->> macros.

And I’m not talking about dash.el. I’m talking about built-in thread-first and thread-last.

What are these

If you’re not familiar with these beautiful macros, the main goal is to pipe a value through multiple functions and return the result.

-> passes a value as first argument of next function, then takes the result and passes it as first argument to next function, etc.
->> does the same except that it passes the result as next function’s last argument

Emacs: A few issues of Org-Roam

Intro

It has been almost a year since I started to use Org-Roam. I initially migrated from Obsidian even though I was incredibly happy with it.

Recently I started to take more notes than usual and noticed that Org-Roam has some issues that for me aren’t critical but disturbing.

Issues

No build-in search functionality

There is just no something like M-x org-roam-search.

I’m pretty sure there is no such thing because it’s Emacs and you can search any directory you want very quickly using built-in grep, rgrep or other tools like that. And of course you can make a function off of that and then bind it to a key chord you like.

Org-mode archive with inherited tags

The issue

By default only the tags directly attached to an org record will be saved in the archive file. I want to keep all the tags attached to an org record when I archive it, even the inherited ones.

Explanation

In org-mode tags are inherited by default. In case of org tree like this:

* Header1        :tag1:
** Sub Header1   :subtag1:

you may find that Sub Header1 has :tag1:subtag1: tags attached to it.

Doom Emacs Search Documentation

Just a quick note on how easy it is to actually navigate Doom Emacs documentation and modules.

I initially was a little afraid that I will not be able to understand what each Doom module does and there always will be some hidden functionaltiy that will be hard for me to find.

Fortunately there is M-x M-x doom/help-search-headings that allows me to search through Doom documentation. Specifically it allows me to search through org headings of the documentation.

Doom Emacs - Turn LSP off by default for PHP files

I’m trying to get used to Doom Emacs and one issue I have is that LSP (in my case Eglot) starts automatically when I open up a php project.

I don’t really like it because sometimes I open php files that I don’t need autocompletion for and I don’t want to remember that there is Eglot process now running that I have to stop to save some resources of my laptop.

Trying Doom once again

Almost a year ago I already tried to start using Doom config which I eventually replaced with my own vanilla config.

Today I decided to try it once again. I also wanted to use it in Evil mode to make my hands feel better.

One of my main pain point with someone else’s config is that I don’t know how to handle it, what options are available and why things work in the way they do.

Org Agenda - show archived records by default

If you didn’t know, there are two methods of archiving subtrees in Emacs’ Org-mode.

I often use the latter but the issue here is that all my items got disappeared from Org Agenda view when archived.

You can tell Org Agenda to show archived records by pressing v A in *Org Agenda* buffer. Notice upper-cased A. If you use lowercase a then only internally archived records will be shown.

Emacs & Wgrep

So I just discovered wgrep mode of a grep buffer in Emacs and it’s incredible.

I often use projectile-ripgrep if I need to find something in the project I’m working on. But if I wanted to rename some variables or strings that I grepped I had to go and manually update them or use something like projectile-replace.

But turns out there is wgrep mode that is available from projectile-ripgrep (*rg*) buffer or from *grep* buffer.

Emacs 29 - Straight.el & Native compilation

I just built emacs-plus@29 on my MacOS using --with-native-comp just to see what it is and how it works.

I’ll talk about my impression of it later. Let’s start with the issue.

I use straight.el + use-package and as soon as I started my new Emacs instance I’ve got this:

Debugger entered--Lisp error: (void-variable native-comp-deferred-compilation-deny-list)
straight--build-native-compile((:type git :host github :repo "radian-software/straight.el" :files ("straight*.el") :branch "master" :package "straight" :local-repo "straight.el"))
straight--build-package((:type git :host github :repo "radian-software/straight.el" :files ("straight*.el") :branch "master" :package "straight" :local-repo "straight.el") nil)
#f(compiled-function () #<bytecode 0x13b193a2e77f4e46>)()
straight--transaction-exec(use-package-\"c809124e9c5270ea1c72e2c3507331d1\"-nil-nil :now #f(compiled-function () #<bytecode 0x13b193a2e77f4e46>))
straight-use-package((straight :type git :host github :repo "radian-software/straight.el" :files ("straight*.el") :branch "master"))
load-with-code-conversion("/Users/krydos/.emacs.d/straight/repos/straight.el/..." "/Users/krydos/.emacs.d/straight/repos/straight.el/..." nil t)
load("/Users/krydos/.emacs.d/straight/repos/straight.el/..." nil nomessage)
(let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 6)) (if (file-exists-p bootstrap-file) nil (save-current-buffer (set-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/..." 'silent 'inhibit-cookies)) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage))
load-with-code-conversion("/Users/krydos/.emacs.d/init.el" "/Users/krydos/.emacs.d/init.el" t t)
load("/Users/krydos/.emacs.d/init" noerror nomessage)
startup--load-user-init-file(#f(compiled-function () #<bytecode 0x155c027c85bc7d>) #f(compiled-function () #<bytecode -0x1f3c61addc0da035>) t)
command-line()
normal-top-level()

It looks like for some reason straight.el expects native-comp-deferred-compilation-deny-list variable available in Emacs while this variable was renamed to native-comp-jit-compilation-deny-list.

Search for hash(#) sign using Emacs' consult-grep

This is something I came across recently. I wanted to search for #todo using M-x consult-grep.

My initial #todo query didn’t work obviously because # sign in consult is a punctuation character as they call it.

I didn’t really want to change # sign as a punctuation character because I used to it. I’m not also sure if there is such an option (read til the end to find out why)

Emacs. Change inner/outer like in Vim

If you’re a former Vim user there is one feature I couldn’t find in any other editors.

Not sure what is the proper name of it but let’s call it change inside something.

Example (| - is a cursor):

function() {
  return 'hello |world'
}

If I press ci' the result is going to be:

function() {
  return '|'
}

or ci{:

function() {|}

That’s incredibly useful feature because I don’t really need to think where my cursor is. I just place it somewhere around the place I need to remove and press that magical keybinding.

Facebook webhooks won't accept Ngrok and Localtunnel anymore

If you want to test webhooks locally you probably use Ngrok or Localtunnel. I do.

Recently I wanted to play with Instagram webhooks and I couldn’t because surprisingly Facebook do not accept Ngrok and Localtunnel URLs anymore and marks them as malicious and/or abusive.

I don’t really understand why Facebook blocked the only known solutions of local webhooks testing.

Fortunately I have a server and a domain name.

Solution

What we’ll need:

MacOS Appearance Auto - theme isn't changing

I recently started to appreciate light theme again. Feels great during a day light.
Still, I like the dark mode too but now I just want to see it at night.

And fortunately, for those who likes both themes, there is a mode called “Auto” in the MacOS settings.

Hooray! Problem solved.

Not really

In case you haven’t configured Night Shift feature then it’s not going to work.

Eglot & PHP & Phpactor

Trying out eglot at the moment on a php project I have and unfortunately it doesn’t work out of the box.

The issue is that my PHP project is based on PHP8 and php-language-server is pretty old server that doesn’t support new php versions.

There are bunch of other LSPs for PHP and I would like to play with Phpactor which I never used before.

Fortunately eglot supports any LSP server and Phpactor has one too.

Emacs ledger-mode with hledger

Hledger is a text based accounting tool. It’s very similar to Ledger (hence the name).

Emacs has great ledger-mode but if you use Hledger you’ll definitely get some issues.

TLDR

here is my use-package block where most of the issues are solved

(use-package ledger-mode
  :straight t ;; or :ensure t
  :init
  (add-to-list 'auto-mode-alist '("\\.\\(h?ledger\\|journal\\|j\\)$" . ledger-mode))
  (setq ledger-binary-path "path-to-fix-hledger-script.see-below")
  (setq ledger-mode-should-check-version nil)
  (setq ledger-report-links-in-register nil)
  (setq ledger-report-auto-width nil)
  (setq ledger-report-native-highlighting-arguments '("--color=always"))
  (setq ledger-highlight-xact-under-point nil)
  (setq ledger-default-date-format ledger-iso-date-format))

Add new transactions issue. xact.

There an error appears when you try to add a new transaction that says xact isn’t available. xact is a tool that comes with ledger but it doesn’t exists in hledger package.

Vim Tabs in Emacs

Immediately few things to mention.

First: we’re going to talk about Tabs as in “UI element”. Not indentation.
Second: Tabs in Vim and Emacs are not supposed to be used as tabs in many other editors.

Vim Tabs

Vim tabs aren’t supposed to be tabs similar to other editors where you have a file per tab and then switch those tabs with your mouse (???!). There are buffers for that.

Ditching Doom

In my previous post I’ve been talking about Doom config and that it is great and all but I find it really difficult to fix issues there. Doom has a lot of its own configuration, hooks here and there and functions that modifies standard behavior.

It’s probably much easier to go with my own config. I never could stick to spacemacs or doom. I couldn’t stick to similar configs in Vim too. Probably issue on my end :)

Podman detach keys

TLDR;

Add detach-keys = "ctrl-@,ctrl-q" to [engine] section in ~/.config/containers/containers.conf file

Description

I recently switched to Podman and the only issue I faced is CTRL+P won’t work properly inside containers.

That’s exactly the same issue I had with Docker, described in my Docker detach keys post.

The solution from that post doesn’t work since it was purely docker-specific configuration file.

In case of Podman the configuration file is ~/.config/containers/containers.conf.

The line that must be added is detach_keys = "ctrl-@,ctrl-q" (feel free to choose any other sequence).

Getting back to Emacs

I do change my workflow from time to time to keep myself in shape.

Now, once again, I’m trying to switch back to Emacs. This time I decided to go with Doom. I already tried to install use it but it didn’t work well for me and I didn’t bother to change the configuration.

Main functionalities I need

Quick search in a project

That’s something I used ag for in my Vim. I could easily look for a word under the cursor everywhere in the project.

Use systemctl instead of service command

TLDR;

service is less functional wrapper around systemctl command on systemd based distros.

Details

I’m a long time Linux user and got a habit to start/stop things using service command.

I never really thought about what exactly it does. I mean, I know I can start Apache or something else with it and it’s something related to init system of my distro. Usually when you install Apache or PHP-FPM those things become recognizable by service command and you can call service program start when you want to start a service.

Makefile -> Taskfile

Makefile

I add a Makefile to every project I work with. I don’t usually work on C/C++ projects or any other compiled languages but Makefile is good to make aliases for long commands.

Here is an example of short version of Makefile I use:


.PHONY: up
up:
	docker-compose up -d

.PHONY: logs
logs:
	tail -f ./storage/logs/*.log

There are set of aliases / mnemonics that I used to:

UMassCTF '21 Hermit 1 WriteUp

hermit logo

Solution

There is only one form that accepts a file.

The validation of the file is based on extension so we can try and upload shell.php.jpg image with content like this:

<?=`$_GET[0]`?>

When image is uploaded we see the page like this:

hermit logo

Click on See image and we see a blank page with some strange PHP errors. It’s because our “image” expects get param called “0” so let’s add one.

UMassCTF '21 Hermit 2 WriteUp

hermit logo

Solution

The image above is what we see when visiting the challenge URL (104.197.195.221:8087)

That’s strange. Initially I thought the site is down but it’s fine.

Let’s try to connect with NetCat and see what the server tell us and why browser can’t display it.

nc -vvv 104.197.195.221 8087

and response we get back is:

221.195.197.104.bc.googleusercontent.com [104.197.195.221] 8087 (?) open
SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u2

Doesn’t look like valid HTTP resopnse lol. Ok now we know that SSH server is running on that port so let’s try to connect.

Vim Fugitive. :Glog - show a commit author

TL;DR

let g:fugitive_summary_format = "%<(16,trunc)%an || %s"

The path of figuring that line out

Vim-Fugitive is a great package. Recently I started to use :Glog command a lot to look at range of changes added to a branch after git pull.

:Glog <hash>..<another hash>

By default the command only shows a commit hash and its subject.

vm screenshot

I really wanted to see how can I show a commit author name as well.

PHP: visual charset detection of a string

Sometimes in mb_convert_encoding($str, 'UTF-8', 'auto') that latest auto argument won’t work.

To find what charset the string is using you can get all possible charsets, convert your $str into that charset and print it:

foreach(mb_list_encodings() as $charset) {
    echo mb_convert_encoding($str, 'UTF-8', $charset) . ' ----- ' . $chr . "\n";                                                                                                2              }
}

This code may not work for some charsets returned by mb_list_encodings(). You can ignore some of them like this:

foreach(mb_list_encodings() as $charset) {
    if (in_array($chr, ['pass', 'wchar', 'byte2be', 'byte2le', 'byte4be', 'byte4le', 'BASE64', 'UUENCODE', 'HTML-ENTITIES', 'Quoted-Printable', '7bit', '8bit'])) {
        continue;
    }
    echo mb_convert_encoding($str, 'UTF-8', $charset) . ' ----- ' . $chr . "\n";                                                                                                2              }
}

Of course it’s only applicable if you know that $str will always be in the charset you found.

My Windows development environment setup

The title is a little bit misleading though. I have almost nothing dev related on my Windows machine and use Linux VM instead.

Here is the components my dev environment consists of:

VMware Workstation

The actual product doesn’t matter here. As I mentioned earlier VirtualBox would work as well. I use VMware because I used to it and I blindly believe in rumors that it is faster than VirtualBox.

Laravel: get all routes and corresponding controllers/actions

If you want to know the handler of a particular route you need to run this in your terminal:

php artisan route:list | grep 'route.name'

Replace route.name with your route name.

In most cases all routes are defined in files from routes/* folder but some routes are defined in Laravel itself or some libraries may define its own routes as well. So in case you want to override some actions from internal controllers just use that command above to understand what exactly you need to override.

Run multiple PostgreSQL instances on one machine

I’m on Ubuntu 18.04 having PostgreSQL 10.10 installed. For testing I had to run PostgreSQL 9.5 along with 10.10.

Installation

If you don’t know how to install version 9 on Ubuntu 18.04 check this doc on postgres site.

To install version 9.5 just run:

sudo apt install postgresql-9.5

That’s it. You should not face any other issues.

Usage

I’ve been always starting postgres instance with sudo service postgresql start but now, when we have two different version we should use:

Vim save file without AutoCmd

Vim’s autocmd is very powerful feature.

In my workflow I have many of them including autocmd for BufWrite.

There are rare cases when I want to save file and ignore any autocmd.

To do this you can just save it by:

:noa w

Of course there can be any command after :noa.

Check :h noa for more details.

Open Tmux on ssh login

Here is few lines you need to add to your .bashrc/.zshrc/.whatevershellrc:

if [[ -z "$TMUX" ]] && [ "$SSH_CONNECTION" != "" ]; then
    tmux attach-session -t mysession || tmux new-session -s mysession
fi

These lines check if tmux session mysession is exist then we tmux attach-session is executed. Otherwise new session with mysession name is created.

Replace mysession to something more meaningful.

How to interview [memo]

Just met this nice article by Laurie Voss called You suck at technical interviews.

Here is TL;DR from there:

Here is the link to original post

Youtube Hide opinion for Google Chrome

Today I decided to port my Firefox extension to Google Chrome.

Meet Youtube Hide Opinion For Chrome.

Turned out, I should change nothing in the extension to make it working in Google Chrome (thanks to Browser Extensions specification)

Now to kill the good feeling I have to say that to publish the extension to WebStore I had to make $5 one-time payment. Pretty symbolic payment but still feels foreign while publishing open source code.

Youtube Hide opinion

Watching videos on Youtube I’ve noticed I influenced a lot by paying attention to a video rating. For example if rating is negative I initially treat a video as unprofessional or even stupid.

I tried to ignore a video rating but it’s pretty hard so I decided to build a browser extension that should hide the rating.

So meet Youtube hide Opinion the Firefox extension.

fun first

As you can see you still can up/down vote a video but you don’t see it’s rating.

git grep --untracked

Turned out I use git grep a lot with my VIM (using EasyGrep plugin). At some point this plugin just stopped to show me all the available results.

Due to lack of explicit git grep usage it was pretty mysterious.

The reason is that git grep doesn’t search in untracked files. If you want to search in untracked files too just add --untracked option to the command like this:

git grep --untracked SomethingILookingFor *

Official git grep doc

MacOS fix not stable WiFi (ping spikes)

hey,

I currently use Windows machine but I do programming inside Linux virtual machine and inside MacOS driven laptop (some iOS specific stuff) which is in the same room where I am and connected to the local network.

Since I develop in Vim I use SSH connection to run Vim instance directly on MacOS machine. If I need anything graphical (like Xcode) I use VNC client.

Issue

SSH connection is super non-stable. It’s pretty painful to use Vim with very slow connection. If I try to ping my MacOS laptop I can see clearly some ping spikes. Usual ICMP travel time is about 3ms but sometimes I get 700ms or 1000ms. Insane.

VNC, MacOS, and frozen login screen

Sometimes my VNC client just shows me Mac’s login screen with infinitely loading animation. If it happens for you too, you can try to login via SSH and run this command:

sudo pkill loginwindow

Now you can try to connect trough VNC and it should work.

Basically it just kills the process of login window and MacOS just runs it again automatically.

Reminders with WSL

Hi everyone,

I was looking for an app that should allow me to set a quick reminder without any additional functionality.

The one was found, it is at binary which is available by default on most (if not all) Linux distributions (checkout man at). Shortly, the at command allows you to specify a command and time you want to run that command at.

My current setup

What I want, is to get a notification at some special time. For notifications we can use notify-send, but since I’m currently on Windows and use WSL, we will use my wsl-notify script (checkout for notify-send replacement for WSL post)

notify-send replacement for WSL

Hi,

Unfortunately there is no way currently to make brilliant notify-send work on WSL.

Solution

The workaround is to install BurntToast which is powershell module (or command) that allows you to show native notifications. After it’s installed we can write a script that can execute PowerShell “cmdlet” from within WSL.

Details

So when BurntToast is installed let’s create a super simple bash script (name it like wsl-notify)

#!/usr/bin/env -bash

powershell.exe "New-BurntToastNotification -Text \"$1\""

Give our wsl-notify execution rights (with chmod +x wsl-notify) and move it to /usr/bin folder with mv wsl-notify /usr/bin/

React Native. Turn off warnings

Sometimes it’s annoying to get those warnings while you work on the layout stuff.

Based on RN documentation you can turn them off by setting:

console.disableYellowBox = true;

You can put it inside your App.js file. I don’t suggest you to commit this but as temporary string is definitely acceptable.

Vim, format JSON file

I have to note it, it’s just brilliant!

If you want to format a JSON file opened in Vim then just run

: %!python -m json.tool

Stolen from this awesome post - Format JSON in Vim using Python’s json.tool module

Tmux. Change default start directory

Hi,

if you use tmux you could notice that every time you create new window it starts in the directory where you initiated your Tmux session.

Usually I start my Tmux at home directory but when I work for a project I like to have all my windows to be opened in this particular project.

Sure I can close the session and start the new one from the project directory but… no.

Vim folding

Hi, I didn’t use folding functionality previously at all in any other editors, but after I watched this awesome video by Greg Hurrell I found this Vim feature super useful.

So to start getting all benefits from Vim folding just add this to your .vimrc:

set foldmethod=indent
set foldlevelstart=1

What these lines do is: