Tagfaq

How To Edit A Vim Macro?

H

I use macros (by the way this is plural of macro) pretty often in my daily workflow. There are always some tasks that you need to do quickly on a large text file, and that’s where macros shine. Sometimes though it’s not trivial to get a macro right from the first time. But do you know there’s a simple hack to modify an already recorded macro without re-recording it? First, a...

Vim search and replace

V

Search and replace. How do you do this in Vim? The basics :s/fn/function/g 1 :s/fn/function/g %s stands for “substitute” here. In this example, we’re replacing all the occurrences of the “fn” string with “function” in the current line. The "g" flag at the end specifies that we need to do this globally, i.e. throughout the whole line. Usually though you...

How to track retention and other metrics with Rails

H

As someone who can’t stop coming up with new side-projects written in Rails, I know how crucial it is to give attention to your data. It’s very important to understand some key metrics, like how many users being registered in a particular week, how many users continue using the product (retention), what are the features being used, etc. Here’s an example of the real admin...

How to copy and paste a line in Vim?

H

One of the most common task that beginners struggle to do in Vim is copying and pasting a line. In reality though, it is very simple. Type "yy" to copy a line, then "p" to paste it into the other place. 1 Type "yy" to copy a line, then "p" to paste it into the other place. Now if you have some time, let’s take a closer look at what’s happening there. To copy a line, Make sure...

How to quit VIM (saving or ignoring the changes)?

H

There are multiple ways of exitting VIM, but it depends on whether you actually want to save your changes or not. Quitting without saving any changes Press Esc to make sure you’re back to the normal mode. Then type :qa!and press Enter. If you would like to know what does it mean: : starts the command, q means “quit”, a means “all” (all...

Recent Posts

Categories

Meta