

在Vim中用Markdown写Hugo
source link: https://note.qidong.name/2017/07/01/vim-markdown-for-hugo/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

在Vim中用Markdown写Hugo
2017-07-01 22:21:50 +08 字数:858 标签: Vim Markdown Hugo
本文介绍Vim写Markdown的基本姿势,以及为Hugo做出的调整。
vim-markdown ¶
在Vim中写Markdown,vim-markdown是一个绕不开的插件。
它不仅提供了Markdown的语法高亮,还提供了代码片的语法高亮!
安装vim-markdown ¶
这里只介绍Vundle.vim这一种方式。 使用其它方式的人,应该也不用介绍。
Plugin 'plasticboy/vim-markdown'
调整 ¶
let g:vim_markdown_toc_autofit = 1
let g:vim_markdown_conceal = 0
let g:tex_conceal = ''
let g:vim_markdown_math = 1
let g:vim_markdown_toml_frontmatter = 1
上面的调整,可以通过:help vim-markdown
查看详情,
也可以在vim-markdown的README.md中查看。
这里,除了对vim-markdown的行为做了个性化调整, 也为Hugo中TOML形式的Front Matter,提供了支持。
操作 ¶
主要操作只有一个,:Toc
。
在Quickfix窗口打开一个Table of Content列表。
此外就是[[
或]]
,跳转到上一个或下一个标题。
tabular ¶
这是一个自动排列的插件,常用于对齐=
、:
等。
当然,它可以对齐任意符号,包括Markdown表格的|
。
安装 ¶
Plugin 'godlygeek/tabular'
排列表格 ¶
在一个表格的第一行,输入命令:Tabularize /|<CR>
,即可对齐。
自动对齐 ¶
在.vimrc
中添加这一段,可以在写完表头后,输入|
的同时,达到排列的效果。
inoremap <silent> <Bar> <Bar><Esc>:call <SID>table_auto_align()<CR>a
function! s:table_auto_align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|'
\ && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
在[vimcasts.org]上,有一个著名的视频介绍Aligning text with Tabular.vim。 这一用法,最初就是来源与此。
goyo.vim ¶
goyo.vim,这是一个提高写作专注力的插件。
它把行宽限定为80(可调整),并且调整到最中间。 同时,隐藏了当前编辑区以外的几乎所有内容,令人更专注地写作。
官方展示图:
Plugin 'junegunn/goyo.vim'
let g:goyo_width = 100
这里,孤把行宽调整为100。
Hugo预览 ¶
由于是在Hugo中写作,所以只需要在终端开着hugo server --buildDrafts
,
就可以在浏览器里访问(默认的)1313端口,查看保存的转换效果。
如果利用系统的分屏功能,就可以实现左边写作、右边预览的效果。
当然,孤更喜欢用双屏。
Recommend
-
35
I’ve recently decided to attempt to keep all of my notes and everything I’ve learned in a Zettelkasten . After reading
-
53
-
13
使用Mermaid在hugo的Markdown中绘制UML 2020-07-31 22:01:02 +08 字数:959 标签: Hugo
-
12
在Hugo中为Markdown内容设置首行缩进 2017-07-31 14:38:53 +08 字数:793 标签: Hugo
-
16
VANCOUVERBuilding Evergreen Notes with Hugo, Markdown, and Docker
-
17
-
12
Vim-Flavored-Markdown Add-on to Tim Pope's markdown.vim to highlight using Github Flavored Markdown. a syntax plugin that extends the Tim Pope's markdown syntax...
-
17
用 VIM 和 markdown 格式写学术论文Skip to content 概要 相对于其它选择来说,markdown 格式方便人更专注于文章内容的写作。然而它...
-
9
Vim Markdown Syntax highlighting, matching rules and mappings for the original Markdown and extensions. Installation If you use
-
4
从 Notion 导出 markdown 到 hugo 项目 从 Notion 导出 markdown 到 hugo 项目 2021-04-12 17:25 folder
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK