用Vim写博客

安装UltraBlog.vim,用Vim写博客

其实先前我是在用我修改版的vimrepress的。
UltraBlog.vim可以说开发也有一段时间了,记得是去年就已经有在开发了,不过我那时候觉得vimrepress还不错,自己改改用着也行。现在试了下UB,真的非常给力。
官方主页:UltraBlog.vim

(ps:本文内容全部通过UltraBlog.vim发送)

安装依赖库

在Archlinux下安装:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sudo pacman  -S  --needed python2-sqlalchemy
sudo pacman  -S python2-markdown
yaourt  -S  --needed python-html2text
#sudo pacman -S --needed python-markdown
#由于现在的Vim基本上是带python 2.7 接口的,因此要指定装python2版的库
( 1 / 1 ) installing python-html2text                   [ ######################] 100%
== > Packages no longer required by any installed package:
    python2-distribute
missing dependency  for mach64-dri :  libgl=7.11.2
missing dependency  for mga-dri :  libgl=7.11.2
missing dependency  for r128-dri :  libgl=7.11.2
missing dependency  for sis-dri :  libgl=7.11.2
missing dependency  for tdfx-dri :  libgl=7.11.2

sudo pacman  -Ru mach64-dri mga-dri r128-dri sis-dri tdfx-dri

修正:
经测试发现,pytho-markdown不能正常处理pre标记(代码中若有空行会被p标记包裹),后来xbot(UltraBlog.vim的作者)说他一直在用python-markdown2,速度比python-markdown
要快,且没有发现此问题,于是我也把python-markdown
卸载了,安装python-markdown2 .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
sudo pacman  -Ru python2-markdown
sudo pacman  -Ru python-markdown
git clone https: //github.com /trentm /python-markdown2.git
cd python-markdown2
sudo python2 setup.py  install
Password: 
running  install
running build
running build_py
creating build
creating build /lib
copying lib /markdown2.py - > build /lib
running build_scripts
creating build /scripts- 2.7
copying and adjusting bin /markdown2 - > build /scripts- 2.7
changing mode of build /scripts- 2.7 /markdown2 from  644 to  755
running install_lib
copying build /lib /markdown2.py - >  /usr /lib /python2.7 /site-packages
byte-compiling  /usr /lib /python2.7 /site-packages /markdown2.py to markdown2.pyc
running install_scripts
copying build /scripts- 2.7 /markdown2 - >  /usr /bin
changing mode of  /usr /bin /markdown2 to  755
running install_egg_info
Writing  /usr /lib /python2.7 /site-packages /markdown2-1.3.2-py2.7.egg-info

安装插件

从git clone :
这是我的一个fork版,做了一点点修改:

1
git clone  git @github.com:ihacklog /UltraBlog.vim.git

ps:此插件支持vundle.

配置

配置sample:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
let ub_blog = {'login_name':'BLOG-USER-NAME',
            \'password':'USER-PASSWORD',
            \'url':'http://ihacklog.com/',
            \'db':'~/.vim/UltraBlog.db'
            \}
" Default page size of local post list, see :help ub_local_pagesize for more information
let ub_local_pagesize = 30

" Default page size of remote post list, see :help ub_remote_pagesize for more information
let ub_remote_pagesize = 15

" Default page size of search result list, see :help ub_search_pagesize for more information

let ub_search_pagesize = 30

" Proudly show your visitors that you are blogging with the world's most powerful editor
let ub_append_promotion_link = 1

" Set width of the local id column in post or page lists
let ub_list_col1_width = 7

" Set width of the remote id column in post or page lists
let ub_list_col2_width = 8

" Set width of the status column in post or page lists
let ub_list_col3_width = 11
" Set this value to 1 if you want to use editor mode.
let ub_editor_mode = 0

" Set this value to 1 if you want to save posts/pages immediately after they are fetched from the blog.
let ub_save_after_opened = 0
" Set this value to 0 if you do not want to save posts/pages immediately after they are sent to the blog.
let ub_save_after_sent = 1

" Set the following options to use a custom extenal command as the converter.
let ub_converter_command = 'pandoc'
let ub_converter_options = ['--reference-links']
let ub_converter_option_from = '--from=%s'
let ub_converter_option_to = '--to=%s'
" Customize hotkeys
let ub_hotkey_open_item_in_current_view='<enter>'
let ub_hotkey_open_item_in_splitted_view='<s-enter>'
let ub_hotkey_open_item_in_tabbed_view='<c-enter>'
let ub_hotkey_delete_item='<del>'
"Set the link template string for images uploaded by :UBUpload
"let ub_tmpl_img_url="markdown###![%(file)s][%(url)s]\n[%(file)s]:%(url)s"
" Set the default template to use when previewing posts/pages locally
let ub_default_template="default"

把上面的内容用户名/密码/博客地址修改成你自己的。保存下。

ps:这个python2-markdown库解析貌似有点问题,
在pre中包含的东西如有空行,会加入p标记。

然后在.vimrc中加上:

1
2
3
4
"UltraBlog.vim
if  filereadable ( $HOME  .  '/.UltraBlog.vim.conf' )
    source  $HOME /.UltraBlog .vim .conf
endif

截图:
UltraBlog.png

基本命令

1
2
3
4
5
6
7
8
UBNew
UBNew post
UBNew page
UBSave
UBSend
UBList
UBOpen post post_id  [ local |remote ]
UBDel post post_id  [ local |remote ]

在博客中输入代码的话,建议使用pre标记,以便在WP中用插件高亮代码。

演示

这里录了一小部分演示,时间有限,就没有把全部命令演示了。。。

UltraBlog-screenshot-2.png 

– EOF –
markdown语法:Daring Fireball: Markdown Syntax Documentation

Posted via UltraBlog.vim.


原文地址:http://ihacklog.com/post/write-blog-with-ultrablog-plugin-in-vim.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值