A Quickstart guide to setting up Vim for blogging
Tags: vim, writing, productivity
Published: 2021-09-11 04:22:46

Vim is an **extremely powerful** editor.

But coding is not the only thing I use vim for (Guess where I'm writing this post?) Vim understands the structure of natural language, and you can jump between paragraphs, change words, delete sentences – With Vim you can edit at the speed of thought.

But writing in Vim won't be _that_ smooth with your coding setup – you'll need a few plugins and mappings to make it better. Here, I'll show you how to quickly get started in blogging with Vim without going into too much detail.

I'm going to assume you know basic Vim stuff, so if you don't, go learn the basics first!

## Screenshot, please!

Here's me editing this post in Vim. So meta, don't you think?

![Screenshot of vim editing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vs2y6zv7dan47zu03sr3.png)

## General settings

I've set all the _"good" stuff_ which we should set anyways, like `syntax`, `spell`, `cursorline`, and `cursorcolumn`. Set those for the best effect.

## Mappings

Moving lines is one common thing I usually do while writing posts, so I've mapped this:

```vim
noremap + ddp
noremap - ddkkp
```

I've also made my scroll "smooth" XD:

```vim
noremap <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y>
noremap <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E>
```

Also, I've set up vim to insert a space after a comma:

```vim
inoremap , ,<space>
```

I also added a bunch of operator pending mappings to make editing in quotes and braces easier:

```vim
onoremap in( :<c-u>normal! f(vi(<cr>
onoremap in{ :<c-u>normal! f{vi{<cr>
onoremap in" :<c-u>normal! f"vi"<cr>
onoremap in' :<c-u>normal! f'vi'<cr>
onoremap in` :<c-u>normal! f`vi`<cr>

onoremap il( :<c-u>normal! F(vi(<cr>
onoremap il{ :<c-u>normal! F{vi{<cr>
onoremap il" :<c-u>normal! F"vi"<cr>
onoremap il' :<c-u>normal! F'vi'<cr>
onoremap il` :<c-u>normal! F`vi`<cr>
```

This lets you do stuff like **c**hange the text **i**n the **n**ext **(**s using `cin(` or **y**anking (copying in vim is called yanking) **i**n the **l**ast (**l**ast because previous would conflict with vim mappings) code in **`**s by running `cil"`.

The next is a mapping to change the text in the current heading:

```vim
augroup header
	autocmd FileType markdown :onoremap ih :<c-u>execute "normal! ?^#\\+.*$\r:nohlsearch\rwv$"<cr>
	autocmd FileType markdown :onoremap ah :<c-u>execute "normal! ?^#\\+.*$\r:nohlsearch\rv$"<cr>
augroup END
```

This way you can `cih` to change in the header and `cah` to change in the next header.

Another important mapping is to change a word:

```vim
nnoremap <Leader>c *``cgn
nnoremap <Leader>C #``cgn
```

If you run `<leader>c`, the current word will be deleted and you can type anything instead of that. Hit `.` and the same will happen to the next matching word! `<leader>C` does the same, but goes backward.

## Plugins!

I use a lot of plugins, and I'll show you my vim markdown ones here.

### Looks

For the centered editing and focus mode, I use [Goyo](https://github.com/junegunn/goyo.vim) and [Limelight](https://github.com/junegunn/limelight.vim). There are alternatives, but these are the ones I use.

For the syntax highlighting, I use Tim Pope's [markdown runtime](https://github.com/tpope/vim-markdown). Tim Pope is a magician at these things.

### Lexical stuff

For grammar and spellchecking, I use many plugins. The main one is [Pencil](https://github.com/preservim/vim-pencil). I also use [Vim Ditto](https://github.com/dbmrq/vim-ditto), [Lexical](https://github.com/preservim/vim-lexical), and [Wordy](https://github.com/preservim/vim-wordy)

I also use [autopairs](https://github.com/jiangmiao/auto-pairs) to get nicely autoclosed quotes.

That's just about it. There is more stuff I use, but these are the main ones. 

Thanks for reading! If you like this stuff, check out my [Twitter](https://twitter.com/SiddharthShyn) or [Tweet this post](https://twitter.com/intent/tweet?url=https%3A%2F%2Fdev.to%2Fsiddharthshyniben%2Fa-quickstart-guide-to-setting-up-vim-for-blogging-1ia1&text=Vim%20is%20an%20awesome%20editor,%20but%20with%20a%20bit%20of%20tweaking%20you%20can%20make%20it%20your%20blogging%20tool%20too!%20Check%20out%20this%20post%20for%20more) (Yeah, I've gotten a bit self promotion-ey)

![Screenshot of vim editing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vs2y6zv7dan47zu03sr3.png)

[congrats]: https://Congrats-on-finding-the-first-clue!-The-Character-you-need-is-"".-And-your-next-clue-is-"id"