LoginSignup
15
13

More than 5 years have passed since last update.

VimでNeoBundleを使えるようにしてMarkdownの環境を整える

Posted at

最近Githubを使うことが多くなってきたので,Markdownを書けるようになりたいなと思って環境構築.

  • OS X El Capitan バージョン 10.11.3
  • VIM version 7.3

NeoBundle とは

参考:NeoBundle - neovim/vim入門

NeoBundleとは、vimのプラグイン管理(プラグインマネージャ)のプラグインです。NeoBundleは、Vundleをベースにしています。Vundleとは違うコマンド名になっています。もし、今からプラグインマネージャーを使うのであれば、Vundleではなく、NeoBundleを使うべきです。vimのプラグインのインストールやアップデートを簡単に行えます。非同期実行のサポート、unite.vimの対応、リビジョン指定など、大幅に機能が強化されています。NeoBundleの開発は終了したため、VimとNeoVimのプラグインマネージャDein.vim を利用しましょう。

NeoBundleのインストール

参考:Shougo/neobundle.vim / Quick start - GitHub
NeoBundleが置かれているGitHubレポジトリのQuick startを参考.

  1. Setup NeoBundle: ターミナルで以下のコマンドを実行
$ mkdir -p ~/.vim/bundle
$ git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
  1. Configure bundles: .vimrcに以下の設定を記述.
.vimrc

 " Note: Skip initialization for vim-tiny or vim-small.
 if 0 | endif

 if &compatible
   set nocompatible               " Be iMproved
 endif

 " Required:
 set runtimepath^=~/.vim/bundle/neobundle.vim/

 " Required:
 call neobundle#begin(expand('~/.vim/bundle/'))

 " Let NeoBundle manage NeoBundle
 " Required:
 NeoBundleFetch 'Shougo/neobundle.vim'

 " My Bundles here:
 " Refer to |:NeoBundle-examples|.
 " Note: You don't set neobundle setting in .gvimrc!

 call neobundle#end()

 " Required:
 filetype plugin indent on

 " If there are uninstalled bundles found on startup,
 " this will conveniently prompt you to install them.
 NeoBundleCheck

書いたら:wqで一旦Vimを終了して,,以下のコマンドを実行.

$ vim +NeoBundleInstall +qall

これでNeoBundleの環境が整ったはず.

Markdownの環境を整える.

参考(VimでMarkdownの環境を整える)[http://www.key-p.com/blog/staff/archives/9032]

以下のプラグインを導入します.

  • vim-markdown
    • syntax highlightingとかやってくれる.
  • open-browser.vim
    • Vimで:PrevimOpenするとブラウザでMarkdownファイルのプレビューができる.
  • previm
    • プレビュー用のプラグイン.:wするとopen-browserで開いているプレビューも更新してくれる.

.vimrcに下記を追加.

.vimrc
NeoBundle 'plasticboy/vim-markdown'
NeoBundle 'kannokanno/previm'
NeoBundle 'tyru/open-browser.vim'

追記したら,
:wで保存.
source $MYVIMRCで.vimrcを再読み込み.
:NeoBundleInstallでプラグインを導入.

このままmだと拡張子が.mkdのファイルに対してハイライトが適用されるらしいので,.mdファイルもMarkdownとして読み込むよう設定.

.vimrc
au BufRead,BufNewFile *.md set filetype=markdown

動作確認

下記のファイルを作成.

test.md
# Header 1
## Header 2
### Header 3

- item 1
- item 2

>This is a blockquotes

| Left align | Right align | Center align |
|:-----------|------------:|:------------:|
| This       |        This |     This     |
| column     |      column |    column    |
| will       |        will |     will     |
| be         |          be |      be      |
| left       |       right |    center    |
| aligned    |     aligned |   aligned    |

書いたら:wで保存.
:PrevimOpenでブラウザがオープンする.
こんな感じで表示されたら終わり.
スクリーンショット 2016-04-04 23.34.20.png

15
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
13