4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VIMを使い倒す…その前に

Last updated at Posted at 2018-03-03

【補足】
vimがインストールされているとシンボリックリンクが設定される為
viコマンドでvimが起動します。
アホな筆者はいつものクセでviコマンドでvimを起動します。ご了承ください。

よーしubuntu入れたぞ!さっそくコーディングだ!

`vi`っと。 エスクプローラを表示しよう。 `:Explore`っと。 **E492: Not an editor command: Explore** あれ、スペル間違えたかな、もう一回やってみよう。 **E492: Not an editor command: Explore** **できない:sob:**

utunbuに最初からインストールされたVIMは非常に低機能

バージョンを確認
$ vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)             
Included patches: 1-1689                                                                              
Extra patches: 8.0.0056                                                                               
Modified by pkg-vim-maintainers@lists.alioth.debian.org                                               
Compiled by pkg-vim-maintainers@lists.alioth.debian.org                                               
Small version without GUI.  Features included (+) or not (-):                                         
+acl             -farsi           -mouse_sgr       -tag_any_white                                     
-arabic          -file_in_path    -mouse_sysmouse  -tcl                                               
-autocmd         -find_in_path    -mouse_urxvt     +terminfo                                          
-balloon_eval    -float           -mouse_xterm     -termresponse                                      
-browse          -folding         +multi_byte      -textobjects                                       
+builtin_terms   -footer          -multi_lang      -timers                                            
-byte_offset     +fork()          -mzscheme        -title                                             
-channel         -gettext         -netbeans_intg   -toolbar                                           
-cindent         -hangul_input    +packages        -user_commands                                     
-clientserver    +iconv           -path_extra      +vertsplit                                         
-clipboard       -insert_expand   -perl            -virtualedit                                       
-cmdline_compl   -job             -persistent_undo +visual                                            
+cmdline_hist    +jumplist        -printer         -visualextra                                       
-cmdline_info    -keymap          -profile         -viminfo                                           
-comments        -langmap         -python          -vreplace                                          
-conceal         -libcall         -python3         +wildignore                                        
-cryptv          -linebreak       -quickfix        -wildmenu                                          
-cscope          -lispindent      -reltime         +windows                                           
-cursorbind      -listcmds        -rightleft       +writebackup                                       
-cursorshape     -localmap        -ruby            -X11                                               
-dialog          -lua             -scrollbind      +xfontset                                          
-diff            -menu            -signs           -xim                                               
-digraphs        -mksession       -smartindent     -xsmp                                              
-dnd             -modify_fname    -startuptime     -xterm_clipboard                                   
-ebcdic          -mouse           -statusline      -xterm_save                                        
-emacs_tags      -mouse_dec       -sun_workshop    -xpm                                               
-eval            -mouse_gpm       -syntax                                                             
+ex_extra        -mouse_jsbterm   -tag_binary                                                         
-extra_search    -mouse_netterm   -tag_old_static                                                     
   system vimrc file: "$VIM/vimrc"                                                                    
     user vimrc file: "$HOME/.vimrc"                                                                  
 2nd user vimrc file: "~/.vim/vimrc"                                                                  
      user exrc file: "$HOME/.exrc"                                                                   
  fall-back for $VIM: "/usr/share/vim"                                                                
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -DTINY_VIMRC -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim    -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo  -lselinux -lacl -lattr -ldl

おお、よく分からんけど色んな機能が無効(-)になっているのは分かる…
バージョン自体は問題なさそう

VIMを新しくインストールすればいい

一旦削除とかしなくても大丈夫みたい。 サクッとインストール。
$ sudo apt install vim

一応、起動前にバージョン見てみよう。

$ vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)
適用済パッチ: 1-1689
追加拡張パッチ: 8.0.0056
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Huge 版 without GUI.  機能の一覧 有効(+)/無効(-)
+acl             +farsi           +mouse_netterm   +tag_binary
+arabic          +file_in_path    +mouse_sgr       +tag_old_static
+autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white
-balloon_eval    +float           +mouse_urxvt     -tcl
-browse          +folding         +mouse_xterm     +terminfo
++builtin_terms  -footer          +multi_byte      +termresponse
+byte_offset     +fork()          +multi_lang      +textobjects
+channel         +gettext         -mzscheme        +timers
+cindent         -hangul_input    +netbeans_intg   +title
-clientserver    +iconv           +packages        -toolbar
-clipboard       +insert_expand   +path_extra      +user_commands
+cmdline_compl   +job             -perl            +vertsplit
+cmdline_hist    +jumplist        +persistent_undo +virtualedit
+cmdline_info    +keymap          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       -python          +vreplace
+cscope          +lispindent      +python3         +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con      -lua             +rightleft       +writebackup
+diff            +menu            -ruby            -X11
+digraphs        +mksession       +scrollbind      -xfontset
-dnd             +modify_fname    +signs           -xim
-ebcdic          +mouse           +smartindent     -xsmp
+emacs_tags      -mouseshape      +startuptime     -xterm_clipboard
+eval            +mouse_dec       +statusline      -xterm_save
+ex_extra        +mouse_gpm       -sun_workshop    -xpm
+extra_search    -mouse_jsbterm   +syntax          
      システム vimrc: "$VIM/vimrc"
      ユーザー vimrc: "$HOME/.vimrc"
   第2ユーザー vimrc: "~/.vim/vimrc"
       ユーザー exrc: "$HOME/.exrc"
       省略時の $VIM: "/usr/share/vim"
コンパイル: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
リンク: gcc   -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm      

おお、よく分からんけど色んな機能が有効(+)になってる
ついでに日本語になっちゃってちょっとダセェ…(学生時代の通知票は英語1)
さっそくVIMを起動してみよう。

$ vi

エクスプローラを表示しよう。

:Explore

" ============================================================================
" Netrw Directory Listing                                        (netrw v155)
"   /home/BakaHoge
"   Sorted by      name
"   Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
"   Quick Help: <F1>:help  -:go up dir  D:delete  R:rename  s:sort-by  x:special
" ==============================================================================
../                                                                                                                                                                                                         
./
.cache/
.config/
.dbus/
.gconf/
.gnome/
.gnupg/
.local/
.mozc/
.mozilla/
.pki/
.presage/
.vim/
Desktop/
Documents/
Download/
Music/
Pictures/
Public/
Templates/
Videos/
work/
.ICEauthority
.Xauthority
.bash_history
.bash_logout
.bashrc
.profile
.sudo_as_admin_successful
.viminfo
.xinputrc
.xsession-errors
.xsession-errors.old
examples.desktop


できたぁぁぁ:sob:

ちなみに日本語環境でubuntuをインストールした場合、Desktop/ とか Download/ とかが日本語表記になりますね。
作業中にディレクトリの移動等をする際日本語のディレクトリがあると面倒なので以下コマンドで英語にしました。
この時、Downloadディレクトリにデータが入っていると新しくDownloadsディレクトリってのが作られるっぽいので
できれば空にしとくといいだろう。


$ LANG=C xdg-user-dirs-gtk-update

あとは /home/.vimrc を作って自分好みにいじれば完了ですね。

まとめ

はじめてVIMを本格的に触った時はすでにガチガチに環境構築してあったからすんなり使えたわけだ。 自分で環境作ると色々見えてくる物がある。 もっと色々試してみると面白いだろう。

今回もいい勉強になりました。

4
4
2

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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?