markdown Vim指南

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Vim指南相关的知识,希望对你有一定的参考价值。

## Tabs & Windows
Open files in multiple tabs.

`vim -o file1.txt file2.txt file3.txt`

o-vertical, O-horizontal

Switch tabs:

`gt ->`

`gT <-`

Switch windows:

`<C+w>w ->`

`<C+w>W <-`

Add permanent hotkey (Tab-key) to switch windows
```
cat ~/.vimrc
:noremap <Tab> <C-W>w
```

## Substitution
`:%s/\<foo\>/bar/gc` Change only whole words exactly matching 'foo' to 'bar'; ask for confirmation.

`:s/foo/bar/g`	Change each 'foo' to 'bar' in the current line.

`:%s/foo/bar/g`	Change each 'foo' to 'bar' in all the lines.

`:5,12s/foo/bar/g`	Change each 'foo' to 'bar' for all lines from line 5 to line 12 (inclusive).

`:'a,'bs/foo/bar/g`	Change each 'foo' to 'bar' for all lines from mark a to mark b inclusive (see Note below).

`:'<,'>s/foo/bar/g`	When compiled with +visual, change each 'foo' to 'bar' for all lines within a visual selection. Vim automatically appends the visual selection range ('<,'>) for any ex command when you select an area and enter :. Also, see Note below.

`:.,$s/foo/bar/g`	Change each 'foo' to 'bar' for all lines from the current line (.) to the last line ($) inclusive.

`:.,+2s/foo/bar/g`	Change each 'foo' to 'bar' for the current line (.) and the two next lines (+2).

`:g/^baz/s/foo/bar/g`	Change each 'foo' to 'bar' in each line starting with 'baz'.

## Fileformat
```
:set fileformat=unix
fileformat=dos
```

Display CRLF as ^M:
```
:e ++ff=unix
```

Substitute CRLF for LF:
```
:setlocal ff=unix
:w
:e
```
```
:set fileencoding=utf8
:w myfilename
:set bomb
```

## Other
In editor u can write in command mode:
`:sh`
to get in into the shell. To move back press `<C-D>`.

`:help` is very helpfull :)

## My .vimrc
```
:noremap <Tab> <C-W>w
set wildmenu
set wcm=<Tab>
menu Encoding.koi8-r  :e ++enc=koi8-r<CR>
menu Encoding.cp1251  :e ++enc=cp1251<CR>
menu Encoding.cp866   :e ++enc=cp866<CR>
menu Encoding.ucs-2le :e ++enc=ucs-2le<CR>
menu Encoding.utf-8   :e ++enc=utf-8<CR>
map <F12> :emenu Encoding.<Tab>
```

以上是关于markdown Vim指南的主要内容,如果未能解决你的问题,请参考以下文章

vim安装markdown插件

新的vim自带markdown插件,请问markdown怎么折叠文本,只显示标

MarkDown的vim插件安装

Markdown 指南

Linux系统里让vim支持markdown格式的语法高亮

Markdown常用使用技巧--完整入门指南