LoginSignup
4
5

More than 5 years have passed since last update.

初心者インフラエンジニアのVIM(勉強中)

Last updated at Posted at 2015-08-03

ググって直感で便利そうなもの足していったものです。
設定書いてあるけど使い方わからないものもたくさんあります(勉強中)

Vim7.4のインストール

$ wget ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2
$ tar xjf vim-7.4.tar.bz2
$ cd vim74
$ ./configure  --enable-multibyte
$ make && make install

Neobundle のインストール

$ mkdir -p ~.vim/bundle
$ git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
$ !vi ~/.vimrc 
$ vim # neobundleのcheck が走ってインストールする? yes!
$ cd ~/.vim/bundle/vimproc/
$ make -f make_unix.mak

コマンドメモ

VimFiler

Mode コマンド
通常 Ctrl+f Vimfiler 開く
通常 l ディレクトリ移動
通常 t ディレクトリ展開
通常 T ディレクトリ全部展開
通常 e ファイル編集
通常 gs セーフモード解除(ファイル作成削除などできる)
通常 N ファイル作成
通常 v 見るだけ
通常 r rename
通常 (dとかcでファイル選択)
→d→yes
削除
通常 (dとかcでファイル選択)
→c→ディレクトリ名
コピー
通常 H Vimshell起動

VimShell

Mode コマンド
Insert Ctrl+l History
History 入力 文字列検索
History yy コマンドコピー
通常 なんでも 上にも行ける+検索などもできる

その他

Mode コマンド
コマンド :vs 横分割
コマンド :sp 縦分割
通常 Ctrl+w ↑↓←→ 操作画面移動
通常 ><+- 画面の仕切り移動

Vimrc

vimrc
syntax on
set fileformat=unix
set t_Co=256

set backspace=indent,eol,start
set laststatus=2
set nohlsearch
set number
set cursorline
set cursorcolumn
set history=100
set showmatch
set hlsearch
set tabstop=2
set autoindent
set expandtab
set shiftwidth=2

" バックアップ
set backup
set writebackup
set backupdir=~/backup

"マウスクリック用
"set mouse=a
"set ttymouse=xterm

"色
highlight Comment ctermfg=03
highlight Search ctermfg=44
highlight Number ctermfg=01
highlight LineNr ctermfg=02
highlight CursorColumn ctermbg=244

inoremap {<Enter> {}<Left><LF><ESC><S-o>
inoremap [<Enter> []<Left><LF><ESC><S-o>
inoremap (<Enter> ()<Left><LF><ESC><S-o>
nnoremap  <C-a> :set paste<Esc>
nnoremap  <C-i> :set nopaste<Esc>

 if !1 | finish | endif
 if has('vim_starting')
   set nocompatible

   set runtimepath+=~/.vim/bundle/neobundle.vim/
 endif

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

   NeoBundleFetch 'Shougo/neobundle.vim'
   NeoBundle 'itchyny/lightline.vim'
   NeoBundle 'Shougo/unite.vim'
   NeoBundle 'Shougo/vimfiler'
   NeoBundle 'Shougo/vimproc'
   NeoBundle 'Shougo/vimshell'

   call neobundle#end()
 NeoBundleCheck

filetype on
filetype plugin indent on
filetype off
filetype plugin indent off
set runtimepath+=$GOROOT/misc/vim
filetype plugin indent on
syntax on
autocmd FileType go autocmd BufWritePre <buffer> Fmt
exe "set rtp+=".globpath($GOPATH, "src/github.com/nsf/gocode/vim")
set completeopt=menu,preview

function! s:SID_PREFIX()
  return matchstr(expand('<sfile>'), '<SNR>\d\+_\zeSID_PREFIX$')
endfunction

" Set tabline.
function! s:my_tabline()  "{{{
  let s = ''
  for i in range(1, tabpagenr('$'))
    let bufnrs = tabpagebuflist(i)
    let bufnr = bufnrs[tabpagewinnr(i) - 1]  " first window, first appears
    let no = i  " display 0-origin tabpagenr.
    let mod = getbufvar(bufnr, '&modified') ? '!' : ' '
    let title = fnamemodify(bufname(bufnr), ':t')
    let title = '[' . title . ']'
    let s .= '%'.i.'T'
    let s .= '%#' . (i == tabpagenr() ? 'TabLineSel' : 'TabLine') . '#'
    let s .= no . ':' . title
    let s .= mod
    let s .= '%#TabLineFill# '
  endfor
  let s .= '%#TabLineFill#%T%=%#TabLine#'
  return s
endfunction "}}}
let &tabline = '%!'. s:SID_PREFIX() . 'my_tabline()'
set showtabline=2 
nnoremap    [Tag]   <Nop>
nmap    t [Tag]
for n in range(1, 9)
  execute 'nnoremap <silent> [Tag]'.n  ':<C-u>tabnext'.n.'<CR>'
endfor

map <silent> [Tag]c :tablast <bar> tabnew<CR>
map <silent> [Tag]x :tabclose<CR>
map <silent> [Tag]n :tabnext<CR>
map <silent> [Tag]p :tabprevious<CR>
map + <C-W>+
map - <C-W>-
map < <C-W><
map > <C-W>>
map <C-F> :VimFiler -split -simple -winwidth=30 -no-quit<CR>
4
5
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
4
5