:noh
Vim
10月27
Vimで初プラグイン
8月4
visualモード
[インデントを修正]
- vを押す(Visualモードに遷移)
- j(上)やk(下)で選択範囲を決める
- =を押す
[選択範囲をカット&ペースト]
- vを押す(Visualモードに遷移)
- h,j,k,lで選択範囲を決める
- dを押す
- 貼付けたい場所に移動後、pを押す
カット&ペースト
- dw: カーソル位置から空白を含む単語の末尾までコピーする
- d$: カーソル位置から行末までコピーする
ファイルの位置、情報
- Ctrl-g :ファイル名と行番号を表示
- G :ファイルの末尾に移動
- gg :ファイルの先頭に移動
- 行番号+G :指定の行に移動
5月6
コピペなどでインデントが崩れてしまった場合の修正:
- 整形したい行の先頭業に移動
- Visualモード(Shift+V)に移動
- 選択範囲を指定(jを連打とか...)
- "="を入力
ubuntu10.04で実施
事前準備
構文チェッカー(pychecker)インストール
$ aptitude install pychecker $ $ pychecker hoge.py # こんな感じで引数にテスト対象プログラムを指定 Processing module hoge (hoge.py)... Warnings... None
- コンパイルする場合
http://i2bskn.hateblo.jp/entry/20120325/1332659360
辞書機能(pydiction)インストール
ここからダウンロードして".vim"ディレクトリに格納
$ cd /tmp; pwd $ wget http://www.vim.org/scripts/download_script.php?src_id=11062 $ mv download_script.php\?src_id\=11062 pydiction-1.2.zip $ unzip pydiction-1.2.zip $ mkdir -p ~/.vim/after/ftplugin/ $ cp pydiction-1.2/python_pydiction.vim ~/.vim/after/ftplugin/ $ mkdir -p ~/.vim/dict $ cp pydiction-1.2/complete-dict ~/.vim/dict/ $ cp pydiction-1.2/pydiction.py ~/.vim/dict/
スケルトン作成
$ cat <py > #!/usr/bin/python > # vim: fileencoding=utf-8 > END $ mv py ~/.vim/skel/
vimrc設定
- 辞書の読み込み
- インデント設定
- 構文チェック
- Ctrl + t : 編集中プログラムに対してpychecker実行
- Ctrl + e: 編集中プログラムの実行
- skeltonの定義
" ------- " Python filetype plugin on autocmd FileType python :map:!pychecker % autocmd FileType python :map :!python % autocmd FileType python let g:pydiction_location = '~/.vim/dict/complete-dict' autocmd FileType python setl autoindent autocmd FileType python setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class autocmd FileType python setl expandtab tabstop=4 shiftwidth=4 softtabstop=4 function! s:ExecPy() exe "!" . &ft . " %" :endfunction command! Exec call ExecPy() autocmd FileType python map :call ExecPy() augroup SkeletonAu autocmd! autocmd BufNewFile *.*py 0r $HOME/.vim/skel/py augroup END
プロフィール
edworld
カテゴリ別アーカイブ
人気記事
記事検索
アクセスカウンター
- 今日:
- 昨日:
- 累計: