u/bkthedeveloperin r/vim • Recommends
Vim Tips Episode 3 - Automatically Increment - Quickly and easily create incremented/decremented lists of numbers/letters/hex/binary Skip to 01:20 to skip the preamble
9.7K subscribers • 6 videos on Hallway
Beginner. No background in the topic needed.
4.2K views5 years ago1 recommendation
Tools and practiceVim, Emacs and editors
Ben Kadel demonstrates how to use Vim's built-in features to automatically increment and decrement lists of numbers, letters, hex, and binary.
Twitter: twitter.com/ben_kadel Github: github.com/kardelio The THIRD instalment in widely acclaimed and massively beloved vim show: VIM TIPS! This series, hopefully, provides small & easily consumable Tips & Tricks in Vim to help you become a better Vim-er and is for Beginners & Intermediate Vim users alike. The aim is to hopefully expose/highlight some of Vim's massive (maybe even lesser known) functionality with explanations & examples. In this episode I show you the incredibly useful functionality, that already exists within Vim, that enables you to very easily increment a list of, well, anything really; from, obviously, normal base 10 numbers to hexadecimal to binary numbers to even LETTERS. Not only can you automatically generate these lists of numbers or letters increasing by one for each line, BUT you can also do the same in reverse and have a list that decrement's its values instead! First of all I show you the key combination that simply increments the value that your cursor is on (CTRL + a). Turning a 1 into a 2 and a 2 into a 3 and so on... However this method sucks when you want to automatically increment an entire list. Instead Vim gives us the super powered key combination of 'g CTRL + a' that takes your visual selection and increments each starting number by one, in order to create an ordered number list in just a few key taps. Not only can you use 'g CTRL + a' to INCREMENT the list but you can also use 'g CTRL + x' to automatically decrement the list instead, counting downwards, if you need that functionality. After that I show you the real power of this key combination and that is that it doesn't just have to increment or decrement NUMBERS, it can also effect Binary values, Octal values, Hexadecimal values and even LETTERS. For the latter you need to simply change one of vim's default settings, called 'nrformats' which basically informs vim what to consider as "numerical values" or more precisely "values-that-can-be-incremented-or-decremented" we can tell Vim to have this effect on letters by adding the 'alpha' option to the nrformats setting, this can be done with the following command: :set nrformats+=alpha After you have added that setting you can effect letters too which enables you to create alphabetically ordered lists too! Ofcourse the letters, binary, octal and hex values can all be incremented OR decremented depending on what that final key is that you hit. Timestamps ====================== - Intro - The situation in Vim - Vim Increment/Decrement Keys - Increment multiple lines (g CTRL + a) - Decrement multiple lines (g CTRL + x) - nrformats setting (enable letter incrementation) - Binary & Hex values too - Outro - Bloopers Links ====================== How to Increment numbers in Vim: irian.to/blogs/quick-vim-tips-to-generate-and-increment-numb… vim.fandom.com/wiki/Increasing_or_decreasing_numbers Incrementing in Vim (IncWhat people say. Recommended as a helpful guide to using Vim's built-in increment and decrement features.
u/bkthedeveloperin r/vim • Recommends