VIMの基本操作 その1
作業内容 * VIM操作方法|! * GitとNeoBoundleのインストール * Vundleのダウンロード
# VIMのバージョン情報等
$vim
VIM - Vi IMproved
version 7.3.1314
by Bram Moolenaar et al.
Vim is open source and freely distributable
Help poor children in Uganda!
type :help iccf<Enter> for information
type :q<Enter> to exit
type :help<Enter> or <F1> for on-line help
type :help version7<Enter> for version info
Running in Vi compatible mode
type :set nocp<Enter> for Vim defaults
type :help cp-default<Enter> for info on this
# vimの使い方を説明してくれる
$vimtutor
"/usr/local/share/vim/vim73/tutor/tutor" [readonly] 970 lines, 33256 characters
"/tmp/tutorwq8T1D" 970 lines, 33256 characters written
===============================================================================
= W e l c o m e t o t h e V I M T u t o r - Version 1.7 =
===============================================================================
Vim is a very powerful editor that has many commands, too many to
explain in a tutor such as this. This tutor is designed to describe
enough of the commands that you will be able to easily use Vim as
an all-purpose editor.
The approximate time required to complete the tutor is 25-30 minutes,
depending upon how much time is spent with experimentation.
ATTENTION:
The commands in the lessons will modify the text. Make a copy of this
file to practise on (if you started "vimtutor" this is already a copy).
It is important to remember that this tutor is set up to teach by
use. That means that you need to execute the commands to learn them
properly. If you only read the text, you will forget the commands!
Now, make sure that your Shift-Lock key is NOT depressed and press
the j key enough times to move the cursor so that Lesson 1.1
completely fills the screen.
[以下省略]
コマンドまとめ
保存:w
保存して終了 :wq
保存せず終了 :q
※ファイルの変更を行い:qで終了させようとすると、
No write since last change (:quit! overrides)が
発生するので、「:q!」で終了する。
一番上へ移動 gg
一番下へ移動 shift + g
画面位置の変更 Ctrl + f
1 行下への移動 Return
左への移動 Back Space
右への移動 Space
先頭行への移動 Ctrl + H
中央行への移動 Ctrl + M
最終行への移動 Ctrl + L
右への移動 Space
先頭行への移動 Ctrl + H
中央行への移動 Ctrl + M
最終行への移動 Ctrl + L
行頭へ移動 ^
行末へ移動 $
文字までジャンプ f(文字)
対応する括弧へ %
前回のコマンドの取り消し u
※もう一度uを押すと、Uコマンド自体が取り消されます。
保存して終了 :wq でも良いが、ZZ(大文字のzを2回)が主流です。
強制保存 :w! (!が強制する記号だと覚えておけばよい)
文字を入力する i
リプレースモード(上書きモード) R
単語のリプレース cw
大文字と小文字の反転 ~
1行上に行を挿入 O(大文字のo(オー))
カーソルの場所から行末までをリプレース C(大文字のC)
行削除 dd
上下左右の移動(カーソルを使わない) h(←)j(↓)k(↑)l(→)
gitのインストール
$cd /usr/ports/devel/git
$sudo make install clean
NeoBundleのインストール
$mkdir -p ~/.vim/bundle
$git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim http://keyamb.hatenablog.com/entry/2013/06/13/164725
# Vundleのダウンロード
$cd ~/.vim
$ git clone git://github.com/gmarik/vundle.git vundle
「.vimrc」にこのように記述
filetype plugin on
set rtp+=~/.vim/vundle/
call vundle#rc('~/.vim/bundle')
Bundle 'petdance/vim-perl'
Bundle 'hotchpotch/perldoc-vim'
Bundle 'Shougo/neocomplcache'
Bundle 'Shougo/neocomplcache-snippets-complete'
Bundle 'thinca/vim-quickrun'
プラグインをインストール
$ git clone https://github.com/Shougo/neobundle.vim.git
下記のようなエラー発生--------------------------------------------------
undle.vim.git
fatal: could not create work tree dir 'neobundle.vim'.: Permission denied
vagrant@vagrant-freebsd-92:/usr/ports/devel/git % cd ~/.vim
vagrant@vagrant-freebsd-92:~/.vim % git clone https://github.com/Shougo/neobundle.vim.git
Cloning into 'neobundle.vim'...
fatal: unable to access 'https://github.com/Shougo/neobundle.vim.git/': Couldn't resolve host 'github.com'