Using Markdown in Vim

Vim does a pretty good job of giving you a stylized preview of your Markdown. Especially when you consider the inherent limitations of an editor that must be able to run within the terminal. For example: Note that italics are handled differently in terminal Vim, because most terminals can’t display italics. If you prefer a more streamlined look, where your text isn’t cluttered by formatting characters for your bold and italic text you can “conceal them. [Read More]

Wrapping Text In Vim

Terminology: Hard Wrap vs Soft Wrap A “soft” wrap is when your text editor just makes the text look like it has been wrapped at the edge of the screen, when in reality it’s just one very long line. This is pretty obvious when line numbers are turned on because there are multiple lines of text but the line number to the left doesn’t increase. A “hard” wrap is when your text editor is configured to actually insert a newline character \n at a predefined width. [Read More]

Showing Invisible Things In Vim

Showing normal invisible characters Sometimes you want to see invisible things. Imagine you’re programming in Python, where it really matters if something is indented with spaces or tabs and the number used matters too. First we turn on list. Sadly, I can’t tell you why. The help docs are all about using lists in VimScript and not what this command does. What I can tell you is that this stuff doesn’t work without it. [Read More]

Vim Registers

If you haven’t done so already, I’d recommend reading the section on “buffers” first. Registers are very similar to buffers they’re just accessed a bit differently. The Yank & Delete Registers (The rolling clipboard) Unnamed Registers When you delete lines of text you are also pushing them onto a stack of 9 numbered registers. Think of it as a rolling clipboard containing the last 9 items. You can put any of the last 9 yanks or deletions into the current text by saying "<num>p where <num> is the number of the register you want to paste. [Read More]

Configuring Vim

Configuring Vim A coworker recently said To change config in vim, you have to be a power user - including understanding how to configure plugins. I’m sorry to say that he is not alone in this belief. Vim won’t hold your hand by giving you a bunch of preferences windows with checkboxes to turn functionality on and off. So, yes it is “harder”, but it absolutely does not require “Power User” levels of understanding. [Read More]

Cursor Movement in Vim

Before we discuss some of the more common, and useful, ones, remember that movement commands become even more valuable when combined with Vim’s verbs. In addition to verbs like Delete, you can combine most of the movement commands with numbers. For example, To jump 30 characters to the right you could say 30→ That’s a silly use-case, but moving down 2 paragraphs? That’s useful. This gets even more useful when we start using visual mode to select sections of text. [Read More]

Cut, Copy, & Paste in Vim

Cut, Copy, & Paste Before we get to any of these, remember that in a graphical Vim client like MacVim all your normal OS cut, copy, and paste commands like ⌘x, ⌘c, and ⌘v (on the Mac) will work just fine when combined with mouse selections. The following commands will make a huge difference in your speed because, they’ll enable you to efficiently rearrange code without ever reaching for the mouse. [Read More]

Editing your .vimrc file

Vim’s core configuration file can be found at ~/.vimrc Without it you’ll have the default configuration: no syntax highlighting, no line numbers, etc.. ~/.vimrc is where you put all your global stuff, like turning on syntax highlighting by default. Editing your ~/.vimrc is something you shouldn’t fear. It’s actually pretty difficult to screw up your Vim configuration so badly that it’s unusable, and in a worst-case-scenario you can always tell vim to ignore it upon launch by saying vim -u NONE and then remove whatever you borked. [Read More]

Emergency Vim Quickstart

EMERGENCY VIM QUICKSTART You’ve ssh’d onto a server. You need to edit a file now. You need to use vim, and you haven’t a clue. You don’t have time for long explanations. Let’s go! READ THIS NOW You’re in the terminal so normal mouse usage for editing isn’t an option. Sorry, that’s a terminal thing, not Vim. Vim has a writing mode, and a not writing mode. You type i to start Inserting text into the document. [Read More]

Hello World in Vim

Every programmer starts a new language by writing hello world, and as you’ll see, Vim is a small DSL for text editing. So, here goes. On the command line, tell Vim you want to create a new text document called hello_world.txt. Note, there are some great grapical Vim clients if you’re not a fan of working on the command line. $ vim hello_world.txt Once you’re in vim, tell it you want to insert some text into this file [Read More]