diff --git a/README.md b/README.md index 0de6d98..2b9b5bb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_435 TILs and counting..._ +_436 TILs and counting..._ --- @@ -422,6 +422,7 @@ _435 TILs and counting..._ - [Backspace Options](vim/backspace-options.md) - [Beginning And End Of Previous Change](vim/beginning-and-end-of-previous-change.md) - [The Black Hole Register](vim/the-black-hole-register.md) +- [Blank Lines Above And Below](vim/blank-lines-above-and-below.md) - [Breaking The Undo Sequence](vim/breaking-the-undo-sequence.md) - [Buffer Time Travel](vim/buffer-time-travel.md) - [Build And Install A Go Program](vim/build-and-install-a-go-program.md) diff --git a/vim/blank-lines-above-and-below.md b/vim/blank-lines-above-and-below.md new file mode 100644 index 0000000..65eff05 --- /dev/null +++ b/vim/blank-lines-above-and-below.md @@ -0,0 +1,23 @@ +# Blank Lines Above And Below + +Generally when I want to add a line above or below the line that the cursor +is on, I use `O` and `o`, respectively. This has a couple potential +drawbacks. First and most prominent, the cursor is moved to the new line and +left in insert mode. Usually, I'd like to remain in normal mode and stay on +the current line. Second, these commands will emulate indentation and other +formatting rules. This is either exactly what you want or a bit of an +annoyance. + +The [`vim-unimpaired` plugin](https://github.com/tpope/vim-unimpaired) +provides an alternative worth adding to your toolbelt. By hitting `[` +and `]`, a new line will be opened above and below the current line, +respectively. Additionally, it leaves you in normal mode, keeps the cursor +on the current line, and moves the cursor to the first non-indented +character. In the case of performing this command in the midst of a comment +in a source code file, neither the indentation nor the comment character +will be propagated onto the new line. + +Hold on to `O`/`o` and `[`/`]` and know the difference. You'll +likely need each of them from time to time. + +h/t Josh Davey