# xserver に vim インストール
たまにしかつかわないから、vi 使うのもいいけど、やはり vim 使いたくなる。。。
目次
- レンタルサーバーなら xserver おすすめ理由
- xserver に nodejs インストール
- xserver に vim インストール
# ncurses をインストール
mkdir ~/opt && cd $_
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz
tar zxfv ncurses-6.1.tar.gz
cd ncurses-6.1
./configure --prefix=$HOME/local
make
make install
# Vim をインストール
cd ~/opt
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge --enable-fail-if-missing --prefix=$HOME/local --with-local-dir=$HOME/local
make
make install
# 環境設定
echo 'export PATH=$PATH:$HOME/local/bin' >> ~/.bashrc
echo "alias vi='vim'" >> ~/.bashrc
source ~/.bashrc
# vim config 設定
~/.vimrc
" ファイルを上書きする前にバックアップを作ることを無効化
set nowritebackup
" ファイルを上書きする前にバックアップを作ることを無効化
set nobackup
" vim の矩形選択で文字が無くても右へ進める
set virtualedit=block
" 挿入モードでバックスペースで削除できるようにする
set backspace=indent,eol,start
" 全角文字専用の設定
set ambiwidth=double
" wildmenuオプションを有効(vimバーからファイルを選択できる)
set wildmenu
"----------------------------------------
" 検索
"----------------------------------------
" 検索するときに大文字小文字を区別しない
set ignorecase
" 小文字で検索すると大文字と小文字を無視して検索
set smartcase
" 検索がファイル末尾まで進んだら、ファイル先頭から再び検索
set wrapscan
" インクリメンタル検索 (検索ワードの最初の文字を入力した時点で検索が開始)
set incsearch
" 検索結果をハイライト表示
set hlsearch
"----------------------------------------
" 表示設定
"----------------------------------------
" エラーメッセージの表示時にビープを鳴らさない
set noerrorbells
" Windowsでパスの区切り文字をスラッシュで扱う
set shellslash
" 対応する括弧やブレースを表示
set showmatch matchtime=1
" インデント方法の変更
set cinoptions+=:0
" メッセージ表示欄を2行確保
set cmdheight=2
" ステータス行を常に表示
set laststatus=2
" ウィンドウの右下にまだ実行していない入力中のコマンドを表示
set showcmd
" 省略されずに表示
set display=lastline
" タブ文字を CTRL-I で表示し、行末に $ で表示する
set list
" 行末のスペースを可視化
set listchars=tab:^\ ,trail:~
" コマンドラインの履歴を10000件保存する
set history=10000
" コメントの色を水色
hi Comment ctermfg=3
" 入力モードでTabキー押下時に半角スペースを挿入
set expandtab
" インデント幅
set shiftwidth=2
" タブキー押下時に挿入される文字幅を指定
set softtabstop=2
" ファイル内にあるタブ文字の表示幅
set tabstop=2
" ツールバーを非表示にする
set guioptions-=T
" yでコピーした時にクリップボードに入る
set guioptions+=a
" メニューバーを非表示にする
set guioptions-=m
" 右スクロールバーを非表示
set guioptions+=R
" 対応する括弧を強調表示
set showmatch
" 改行時に入力された行の末尾に合わせて次の行のインデントを増減する
set smartindent
" スワップファイルを作成しない
set noswapfile
" 検索にマッチした行以外を折りたたむ(フォールドする)機能
set nofoldenable
" タイトルを表示
set title
" 行番号の表示
set number
" ヤンクでクリップボードにコピー
set clipboard=unnamed,autoselect
" Escの2回押しでハイライト消去
nnoremap <Esc><Esc> :nohlsearch<CR><ESC>
" シンタックスハイライト
syntax on
" すべての数を10進数として扱う
set nrformats=
" 行をまたいで移動
set whichwrap=b,s,h,l,<,>,[,],~
" バッファスクロール
set mouse=a
" auto reload .vimrc
augroup source-vimrc
autocmd!
autocmd BufWritePost *vimrc source $MYVIMRC | set foldmethod=marker
autocmd BufWritePost *gvimrc if has('gui_running') source $MYGVIMRC
augroup END
" auto comment off
augroup auto_comment_off
autocmd!
autocmd BufEnter * setlocal formatoptions-=r
autocmd BufEnter * setlocal formatoptions-=o
augroup END
" HTML/XML閉じタグ自動補完
augroup MyXML
autocmd!
autocmd Filetype xml inoremap <buffer> </ </<C-x><C-o>
autocmd Filetype html inoremap <buffer> </ </<C-x><C-o>
augroup END
" 編集箇所のカーソルを記憶
if has("autocmd")
augroup redhat
" In text files, always limit the width of text to 78 characters
autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
augroup END
endif
# Arguments 引数一覧
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 3 2020 12:47:31)
Usage: vim [arguments][file ..] edit specified file(s)
or: vim [arguments] - read text from stdin
or: vim [arguments] -t tag edit file where tag is defined
or: vim [arguments] -q [errorfile] edit file with first error
Arguments:
| オプション | 説明 |
|---|---|
| -- | Only file names after this |
| -v | Vi mode (like "vi") |
| -e | Ex mode (like "ex") |
| -E | Improved Ex mode |
| -s | Silent (batch) mode (only for "ex") |
| -d | Diff mode (like "vimdiff") |
| -y | Easy mode (like "evim", modeless) |
| -R | Readonly mode (like "view") |
| -Z | Restricted mode (like "rvim") |
| -m | Modifications (writing files) not allowed |
| -M | Modifications in text not allowed |
| -b | Binary mode |
| -l | Lisp mode |
| -C | Compatible with Vi: 'compatible' |
| -N | Not fully Vi compatible: 'nocompatible' |
| -V[N][fname] | Be verbose [level N][log messages to fname] |
| -D | Debugging mode |
| -n | No swap file, use memory only |
| -r | List swap files and exit |
| -r (with file name) | Recover crashed session |
| -L | Same as -r |
| -A | Start in Arabic mode |
| -H | Start in Hebrew mode |
| -T <terminal> | Set terminal type to <terminal> |
| --not-a-term | Skip warning for input/output not being a terminal |
| --ttyfail | Exit if input or output is not a terminal |
| -u <vimrc> | Use <vimrc> instead of any .vimrc |
| --noplugin | Don't load plugin scripts |
| -p[N] | Open N tab pages (default: one for each file) |
| -o[N] | Open N windows (default: one for each file) |
| -O[N] | Like -o but split vertically |
| + | Start at end of file |
| +<lnum> | Start at line <lnum> |
| --cmd <command> | Execute <command> before loading any vimrc file |
| -c <command> | Execute <command> after loading the first file |
| -S <session> | Source file <session> after loading the first file |
| -s <scriptin> | Read Normal mode commands from file <scriptin> |
| -w <scriptout> | Append all typed commands to file <scriptout> |
| -W <scriptout> | Write all typed commands to file <scriptout> |
| -x | Edit encrypted files |
| --startuptime <file> | Write startup timing messages to <file> |
| -i <viminfo> | Use <viminfo> instead of .viminfo |
| --clean | 'nocompatible', Vim defaults, no plugins, no viminfo |
| -h or --help | Print Help (this message) and exit |
| --version | Print version information and exit |