安装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.

更多
6 Responses Post a comment
  1. 荒野无灯

    @hilojack
    优点:更灵活的配置、本地sqlite会保留文章的一个备份(断网亦可写博客),支持图片上传等(URL格式可配置)

  2. hilojack

    博主,UB比vimRepress有哪些进步呢?到底有哪些呢?我现在用的是vimRepress呢。。

  3. 互联网战

    大神就是大神,用vim写博客,我是尽量用可视化的编辑器

  4. 荒野无灯

    要安装到系统默认PATH路径下面的。建议使用包管理功能自动安装。

  5. icesnow

    你好,我需要在mac下使用 UltraBlog.vim,但一直不成功。请问如何在mac下安装依赖包呢
    我分别下载安装了SQLAlchemy v0.7 python-markdown2 pandoc,但依然提示cannot find SQLAlchemy,不知为何?

Leave a Reply

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS