mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Blank Lines Above And Below as a vim til
This commit is contained in:
@@ -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)
|
||||
|
||||
23
vim/blank-lines-above-and-below.md
Normal file
23
vim/blank-lines-above-and-below.md
Normal file
@@ -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 `[<space>`
|
||||
and `]<space>`, 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 `[<space>`/`]<space>` and know the difference. You'll
|
||||
likely need each of them from time to time.
|
||||
|
||||
h/t Josh Davey
|
||||
Reference in New Issue
Block a user