SlideShare a Scribd company logo
1 of 65
Download to read offline
Vimカスタマイズ入門
2020年07月19日
自己紹介
名前: 三宅 英明
Twitter: @mollifier
神戸のプログラマ
Vim
Vimは非常に高機が豊富なエディタです
Vimの設定
Vimは自分で設定していろいろカスタマイズできるよ
うになっています
Vimの設定
Vimのカスタマイズ方法の解説と、おすすめ設定を紹
介します
Vimのオプション設定
Vimのオプション設定
Vimをカスタマイズするには、主にオプションと呼ばれ
る設定を使用します。
Vimのオプション設定
Vimにはさまざまなオプションがあります。 オプション
の有効/無効を切り替えるためには、:setコマンドを使
います
Vimのオプション設定
numberオプションを有効にする例
Vimのオプション設定
Vimを起動中に次のコマンドを実行する
:set number
Vimのオプション設定
numberオプションは、行番号を表示するオプションで
す。
:set number
これでnumberオプションが有効になって、行番号が
表示されるようになります。
Vimのオプション設定
オプションを無効にするには、オプション名の前にno
を付けます。
Vimのオプション設定
:set nonumber
たとえば、これでnumberオプションが無効になって、
行番号が表示されなくなります。
Vimのオプション設定
現在の設定状態を知るためには、オプション名の後
に?を付けます。
Vimのオプション設定
:set number?
たとえばこのコマンドを実行すると、numberオプショ
ンが有効であればnumber、無効であればnonumber
と表示されます。
Vimのオプション設定
Vimのオプションには、有効/無効、ではなく値を設定
するものもあります。
Vimのオプション設定
set encoding=utf-8
たとえば、これはencodingオプションにutf-8という値
を設定しています。 値を設定するオプションは、=の右
に設定したい値を書きます。
Vimの設定ファイル
Vimを起動中にオプションを設定しても、終了すると
設定はすべてなくなってしまいます。
Vimの設定ファイル
次回起動したときにも設定を有効にするためには、
Vimの設定ファイルを使用します。
Vimの設定ファイル
Vimの設定ファイルはホームディレクトリ直下の.vimrc
というファイルです。
Vimの設定ファイル
.vimrcの例
:set number
Vimの設定ファイル
.vimrcファイルには、設定したい:setコマンドをそのま
ま書きます。
:set number
Vimの設定ファイル
こうすると、Vimを起動したときに.vimrcに書いたオプ
ション設定が有効になります。
:set number
Vimの設定ファイル
ただし、.vimrcファイルでは先頭の:は省略してよいル
ールになっています。
set number
普通は:を省略して書きます。
Vimの設定ファイル
また、"以降はコメントとして無視されます。
" 行番号を表示する
set number
メモ書きを書いておくと良いでしょう。
Vimの設定ファイル
ところで、なぜわざわざ設定をするのか?
Vimの設定ファイル
Vimは高機能なエディタですが、初期状態では無難
な設定になっています。
Vimの設定ファイル
初期状態では無難 = 便利な設定があるけど明示的
に有効にしないと使えない。
Vimの設定ファイル
というわけで、.vimrcにいい感じに設定を書くと便利
になります。
おすすめのVimの設定
ここまででVimの設定ファイルの書き方が分かりまし
た。
おすすめのVimの設定
じゃあどういう設定をすれば良いの?
おすすめのVimの設定
いろいろあります。最終的にはその人の好みです。
おすすめのVimの設定
ただ、最初のうちは何を設定すればよいか分からない
と思うので、初心者向けのおすすめ設定を紹介しま
す。
おすすめのVimの設定
set number
おすすめのVimの設定
set number
行番号を表示します。有効にしたほうが良いでしょう。
おすすめのVimの設定
set showmode
おすすめのVimの設定
set showmode
インサートモードなどのモードが左下に表示されるよ
うになります。
おすすめのVimの設定
set showcmd
おすすめのVimの設定
set showcmd
入力中のコマンド(c, yなど)が右下に表示されるよう
になります。
おすすめのVimの設定
set incsearch
インクリメンタル検索を有効にする。
おすすめのVimの設定
set incsearch
インクリメンタル検索 = 検索ワードを入力しただけで
確定しなくても検索位置に移動する機能
おすすめのVimの設定
syntax enable
シンタックス ハイライト機能を有効にする。
おすすめのVimの設定
syntax enable
開いているファイルの種類に応じて色付きで表示する
機能
おすすめのVimの設定
filetype indent on
ファイルタイプ インデントを有効にする。
おすすめのVimの設定
filetype indent on
ファイルタイプ インデント = ファイルの種別に応じてイ
ンデント方法を変える機能。
おすすめのVimの設定
filetype plugin on
ファイルタイプ プラグインを有効にする。
おすすめのVimの設定
filetype plugin on
ファイルタイプ プラグイン = ファイルの種別に応じた
設定を有効にする機能。
おすすめのVimの設定
set laststatus=2
ステータスラインを表示する。
おすすめのVimの設定
set laststatus=2
ステータスライン = 画面の下に表示されるアレ。
おすすめのVimの設定
set laststatus=2
0 = 表示しない
1 = ウィンドウ分割したときのみ表示する
2 = 常に表示する。
おすすめのVimの設定
set statusline=%F%m%=%l/%L
ステータスラインに表示する内容の設定。
おすすめのVimの設定
set statusline=%F%m%=%l/%L
%F = 編集しているファイルの絶対パス
%m = ファイル変更フラグ。ファイルの内容を変
更していれば [+] を表示
%= = これ以降は右寄せで表示する
おすすめのVimの設定
set statusline=%F%m%=%l/%L
%l = 現在の行番号
%L = ファイル全体の行数
おすすめのVimの設定
文字コード関連
set encoding=utf-8
set fileencoding=utf-8
おすすめのVimの設定
set encoding=utf-8
set fileencoding=utf-8
encodingは、Vim内部で使われる文字コードです。要
するに、今Vimの画面に表示されている文字列の文
字コードです。
fileencodingは、ファイルに書き込むときに使われる
文字コードです。
おすすめのVimの設定
set encoding=utf-8
set fileencoding=utf-8
普通はencodingとfileencodingは同じ値にします。
fileencodingを省略すると、fileencodingはencoding
と等しいものとみなされます。
おすすめのVimの設定
set fileencoding=cp932
違う文字コードで保存したいときは明示的に
fileencodingで指定します。
おすすめのVimの設定
set fileencodings=ucs-bom,utf-
8,cp932,latin1
fileencodingsは、ファイルを読み込むときにどの文字
コードとみなすかを指定するオプションです。
カンマ区切りで、左から順に試して最初に正しく解釈
できた文字コードを採用します。
おすすめのVimの設定
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-
8,cp932,latin1
世の中にはいろんな環境があるので、厳密にすべて
に対応するのは難しい。 こう書いておけば今の日本
ではだいたい大丈夫。
vimrcの例
https://gist.github.com/mollifier/a5874b96b14cbf0
0d7a36802f91fe25d
vimrcの例
ここに今回紹介した設定ファイルを置いておきました。
最後に
より詳しく理解するには、
:help 'オプション名'
でヘルプを読むと良いでしょう。
最後に
:help 'number'
たとえばこれでnumberオプションの説明が読めます。
最後に
うまく使ってVimライフを楽しんでください。
最後に
ありがとうございました。

More Related Content

Recently uploaded

MPAなWebフレームワーク、Astroの紹介 (その1) 2024/05/17の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その1) 2024/05/17の勉強会で発表されたものです。MPAなWebフレームワーク、Astroの紹介 (その1) 2024/05/17の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その1) 2024/05/17の勉強会で発表されたものです。iPride Co., Ltd.
 
ネットワーク可視化 振る舞い検知(NDR)ご紹介_キンドリル202405.pdf
ネットワーク可視化 振る舞い検知(NDR)ご紹介_キンドリル202405.pdfネットワーク可視化 振る舞い検知(NDR)ご紹介_キンドリル202405.pdf
ネットワーク可視化 振る舞い検知(NDR)ご紹介_キンドリル202405.pdfTakayuki Nakayama
 
2024年5月17日 先駆的科学計算フォーラム2024 機械学習を用いた新たなゲーム体験の創出の応用
2024年5月17日 先駆的科学計算フォーラム2024 機械学習を用いた新たなゲーム体験の創出の応用2024年5月17日 先駆的科学計算フォーラム2024 機械学習を用いた新たなゲーム体験の創出の応用
2024年5月17日 先駆的科学計算フォーラム2024 機械学習を用いた新たなゲーム体験の創出の応用KLab Inc. / Tech
 
LoRaWAN無位置ロープ式水漏れセンサーWL03A 日本語マニュアル
LoRaWAN無位置ロープ式水漏れセンサーWL03A 日本語マニュアルLoRaWAN無位置ロープ式水漏れセンサーWL03A 日本語マニュアル
LoRaWAN無位置ロープ式水漏れセンサーWL03A 日本語マニュアルCRI Japan, Inc.
 
Keywordmap overview material/CINC.co.ltd
Keywordmap overview material/CINC.co.ltdKeywordmap overview material/CINC.co.ltd
Keywordmap overview material/CINC.co.ltdkokinagano2
 
LoRaWAN無位置ロープ型水漏れセンサー WL03A-LB/LSカタログ ファイル
LoRaWAN無位置ロープ型水漏れセンサー WL03A-LB/LSカタログ ファイルLoRaWAN無位置ロープ型水漏れセンサー WL03A-LB/LSカタログ ファイル
LoRaWAN無位置ロープ型水漏れセンサー WL03A-LB/LSカタログ ファイルCRI Japan, Inc.
 
Hyperledger Fabricコミュニティ活動体験& Hyperledger Fabric最新状況ご紹介
Hyperledger Fabricコミュニティ活動体験& Hyperledger Fabric最新状況ご紹介Hyperledger Fabricコミュニティ活動体験& Hyperledger Fabric最新状況ご紹介
Hyperledger Fabricコミュニティ活動体験& Hyperledger Fabric最新状況ご紹介Hyperleger Tokyo Meetup
 
情報を表現するときのポイント
情報を表現するときのポイント情報を表現するときのポイント
情報を表現するときのポイントonozaty
 

Recently uploaded (8)

MPAなWebフレームワーク、Astroの紹介 (その1) 2024/05/17の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その1) 2024/05/17の勉強会で発表されたものです。MPAなWebフレームワーク、Astroの紹介 (その1) 2024/05/17の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その1) 2024/05/17の勉強会で発表されたものです。
 
ネットワーク可視化 振る舞い検知(NDR)ご紹介_キンドリル202405.pdf
ネットワーク可視化 振る舞い検知(NDR)ご紹介_キンドリル202405.pdfネットワーク可視化 振る舞い検知(NDR)ご紹介_キンドリル202405.pdf
ネットワーク可視化 振る舞い検知(NDR)ご紹介_キンドリル202405.pdf
 
2024年5月17日 先駆的科学計算フォーラム2024 機械学習を用いた新たなゲーム体験の創出の応用
2024年5月17日 先駆的科学計算フォーラム2024 機械学習を用いた新たなゲーム体験の創出の応用2024年5月17日 先駆的科学計算フォーラム2024 機械学習を用いた新たなゲーム体験の創出の応用
2024年5月17日 先駆的科学計算フォーラム2024 機械学習を用いた新たなゲーム体験の創出の応用
 
LoRaWAN無位置ロープ式水漏れセンサーWL03A 日本語マニュアル
LoRaWAN無位置ロープ式水漏れセンサーWL03A 日本語マニュアルLoRaWAN無位置ロープ式水漏れセンサーWL03A 日本語マニュアル
LoRaWAN無位置ロープ式水漏れセンサーWL03A 日本語マニュアル
 
Keywordmap overview material/CINC.co.ltd
Keywordmap overview material/CINC.co.ltdKeywordmap overview material/CINC.co.ltd
Keywordmap overview material/CINC.co.ltd
 
LoRaWAN無位置ロープ型水漏れセンサー WL03A-LB/LSカタログ ファイル
LoRaWAN無位置ロープ型水漏れセンサー WL03A-LB/LSカタログ ファイルLoRaWAN無位置ロープ型水漏れセンサー WL03A-LB/LSカタログ ファイル
LoRaWAN無位置ロープ型水漏れセンサー WL03A-LB/LSカタログ ファイル
 
Hyperledger Fabricコミュニティ活動体験& Hyperledger Fabric最新状況ご紹介
Hyperledger Fabricコミュニティ活動体験& Hyperledger Fabric最新状況ご紹介Hyperledger Fabricコミュニティ活動体験& Hyperledger Fabric最新状況ご紹介
Hyperledger Fabricコミュニティ活動体験& Hyperledger Fabric最新状況ご紹介
 
情報を表現するときのポイント
情報を表現するときのポイント情報を表現するときのポイント
情報を表現するときのポイント
 

Featured

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 

Featured (20)

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 

Vimカスタマイズ入門