How do I insert text at the very first column of a line, ignoring indentation?
Answer
gI
Explanation
Most Vim users know I to insert at the start of a line — but I actually jumps to the first non-blank character, skipping leading whitespace. gI is the lesser-known counterpart: it places the cursor at the absolute first column (column 1), regardless of indentation. This matters whenever the content at column 1 is significant.
How it works
I— jumps to the first non-whitespace character on the line, then enters Insert modegI— jumps to column 1 (byte offset 0) unconditionally, then enters Insert mode- Both accept a count:
3gIinserts at column 1 on the current line (count is ignored forgI, unlike some motions)
Example
Given an indented Python line:
def my_function():
With the cursor anywhere on that line:
I→ cursor lands beforedef(column 5), ready to type theregI→ cursor lands at column 1 (before the leading spaces)
Typing # after gI produces:
# def my_function():
Using I instead would have produced:
# def my_function():
Tips
gIis essential when column 1 carries semantic meaning: Makefile rules, FORTRAN continuation lines, HERE-doc delimiters, and diff conflict markers all require content exactly at column 1- In Visual Block mode, use
IorAto prepend/append to all selected lines — these still respect indentation, so for column-1 insertions use a macro withgIinstead - Combine with
.to repeat a column-1 insertion on subsequent lines