Vim Undo And Redo

Today I learned about Vim undo and redo. Undo changes: in normal mode: u to undo latest change, U to undo all changes in Ex mode (command mode): :u to undo latest change Use :u {N} to undo a number of changes. For example, :undo 5 reverts the latest 5 changes. Redo changes: in normal mode: Ctrl+r in Ex mode: :re or :redo In Vim, undo is a tree:
Read more →

Start Vim With Terminal Command

Today I learned that you can start Vim with a terminal command. Vim has the -c flag, which you can use for running an Ex command. The same is true for NeoVim, which also has an inbuilt terminal. So you can either start NeoVim inside the terminal like so: nvim +te or like that: nvim -c ‘:terminal’ The second option allows you to run another command afterwards. Example:
Read more →

Run Macro On Multiple Lines in Vim

Modern editors like VS Code or Sublime Text can use multiple cursors to edit code on more than one line. Vim doesn’t offer this functionality out of the box. But you may not need it. Today I learned how to run a macro to edit several lines in Vim. The method is useful when you have a similar structure on several lines, for example: <li class="link">About</li> <li class="link">Blog</li> <li class="link">Works</li> Add the script visual-at.
Read more →

Reason Option Type

I’m interested in Reason and ReasonReact because it is a typed functional language for the frontend. Today I learned about the Option type. During my experiments with ReasonReact I’m stumbling over some hurdles. I have no experience with typed languages and it shows. Sparse documentation and React’s inherent complexity don’t help. I’m spoiled by bigger communities and more well-known languages, where it’s easy to find material. Still, it’s interesting to learn new concepts and to try to solve problems.
Read more →

TIL: Docker Python Connection Refused

Read more →

VIM: Open a File In a Web Browser on Linux

Today I learned two neat tricks for Vim: Put your cursor on a link (in normal mode), and type gx. This will open the URL in a browser window. What if you want to open a file in a web browser? On Linux, you can type :!xdg-open % to open the current file in the default browser. (On a Mac, just type :!open %) If you want to make sure that your file is saved, you can first update the file and then pipe it through xdg-open:
Read more →

Learning a Little Thing Every Day

Read more →

Phoenix: Use Ecto to Recreate Your Database

Today I learned that it’s a bad idea to drop a PostgreSQL table directly with PGAdmin. Afterwards, I got tons of errors, because the table was missing. I you want to re-create your database from scratch, you should use Ecto. If you want to completely roll back your database and re-create it, use: mix ecto.reset From Codebase: reset is the equivalente of running the following commands: mix ecto.
Read more →

TIL: How to Pass Props to React Router

Just a short note: Today I learned that you shouldn’t pass props to React Router with the component attribute, but with render. From the Docs: When you use component (instead of render or children, below) the router uses React.createElement to create a new React element from the given component. That means if you provide an inline function to the component prop, you would create a new component every render. This results in the existing component unmounting and the new component mounting instead of just updating the existing component.
Read more →

Run PostgreSQL in a Docker Container

I try to learn something new every day, and I find it surprising what cool things you can do with technology. Today I learned that you could run a PostgreSQL database in a docker container. I was doing a Phoenix tutorial by Alvise Susmel. The article shows you how to create a Phoenix app which can handle user uploads and is an interesting piece in itself. But I also like the idea of running the database in Docker for local development.
Read more →