SlideShare una empresa de Scribd logo
1 de 26
Descargar para leer sin conexión
Auto-closing parenthesis 
2014/11/5 VimConf 2014 
cohama / @c0hama
About me 
cohama 
❖ Twitter @c0hama 
❖ from Nagoya 
➢ Nagoya.vim 
❖ Agit.vim, 
the-ocamlspot.vim 
❖ JavaScript, Haskell
Introduction 
reverse(range(1, winnr('$' 
How many ) do we need to type?
Introduction 
while (true) { 
if (p == 1) { 
foo(); 
break; 
How about } ?
Introduction 
❖ We need auto-closing. 
reverse(range(1, winnr('$'))) 
while (true) { 
if (p == 1) { 
foo(); 
break; 
} 
}
For example 
❖ Atom
For example 
❖ Sublime Text
For example 
❖ Eclipse
In Vim...
Table of Contents 
❖ Pure Vim way 
❖ Some Plugins 
❖ About lexima.vim
Table of Contents 
❖ Pure Vim way 
❖ Some Plugins 
❖ About lexima.vim
Pure Vim way 
inoremap ( ()<Left> 
inoremap [ []<Left> 
inoremap " ""<Left> 
Very easy but ...
Pure Vim way but ... 
let w = winnr()) 
let w = winnr) 
let leftparen = "()" 
We need Plugin Power! 
I'm'
Auto-closing requirements 
Before Input After 
| ( (|) 
(|) ) ()| 
(|) <BS> | 
I| 'm I'm| 
syntax-specific rules 
filetype-specific rules
Table of Contents 
❖ Pure Vim way 
❖ Some Plugins 
❖ About lexima.vim
delimitMate 
Raimondi/delimitMate 
❖ some useful features 
<C-G>g 
("foo|") ("foo")| 
❖ unable to dot-repeat
Unable to dot-repeat 
"foo" 
"bar" 
A, "x"<Esc> 
"foo, "x" 
"bar"
Unable to dot-repeat 
j. 
"foo", "x" 
"barx" 
"foo, "x" 
"bar"
vim-smartinput 
kana/vim-smartinput 
❖ highly customizable 
call smartinput#define_rule({ 
 'at': '<%#', 
 'char': '%', 
 'input': '% %><Left><Left><Left>'}) 
❖ unable to dot-repeat 
<% | %> 
% 
<|
Table of Contents 
❖ Pure Vim way 
❖ Some Plugins 
❖ About lexima.vim
About lexima.vim 
cohama/lexima.vim 
❖ highly customizable (inspired by vim-smartinput) 
❖ dot-repeatable 
❖ unstable
lexima.vim's rule definition 
inspired by kana/vim-smartinput 
call lexima#add_rule({ 
 'at': '<%#', 
 'char': '%', 
 'input': '% ', 
 'input_after': ' %>'}) 
compatible with vim-smartinput 
<% | %> 
% 
<|
lexima.vim's endwise-rule 
❖ inspired by tpope/vim-endwise 
❖ Of course, dot-repeatable 
def foo 
| 
end 
<CR> 
def foo|
Mechanism 
In case of (foo<Esc> 
(| 
(|) 
(foo|) 
(foo| 
(foo)| 
(foo|) 
input ( 
call setline() 
input foo 
call setline() 
input ) 
call setpos()
Demo
Thanks

Más contenido relacionado

Similar a Auto closing parenthesis @vim conf2014

Vim Script Programming
Vim Script ProgrammingVim Script Programming
Vim Script Programming
Lin Yo-An
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
guestcf9240
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
Lin Yo-An
 
Tuffarsi in vim
Tuffarsi in vimTuffarsi in vim
Tuffarsi in vim
sambismo
 
Get Soaked - An In Depth Look At PHP Streams
Get Soaked - An In Depth Look At PHP StreamsGet Soaked - An In Depth Look At PHP Streams
Get Soaked - An In Depth Look At PHP Streams
Davey Shafik
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
Lin Yo-An
 
Scalalable Language for a Scalable Web
Scalalable Language for a Scalable WebScalalable Language for a Scalable Web
Scalalable Language for a Scalable Web
Timothy Perrett
 
Start Vim script @Ujihisa.vim 2011/11/19
Start Vim script @Ujihisa.vim 2011/11/19Start Vim script @Ujihisa.vim 2011/11/19
Start Vim script @Ujihisa.vim 2011/11/19
Akihiro Okuno
 

Similar a Auto closing parenthesis @vim conf2014 (20)

Introduction to Vim plugins developed by non-Japanese Vimmer (English version)
Introduction to Vim plugins developed by non-Japanese Vimmer (English version)Introduction to Vim plugins developed by non-Japanese Vimmer (English version)
Introduction to Vim plugins developed by non-Japanese Vimmer (English version)
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11Cranking Floating Point Performance Up To 11
Cranking Floating Point Performance Up To 11
 
Vim Script Programming
Vim Script ProgrammingVim Script Programming
Vim Script Programming
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
 
Cranking Floating Point Performance To 11 On The iPhone
Cranking Floating Point Performance To 11 On The iPhoneCranking Floating Point Performance To 11 On The iPhone
Cranking Floating Point Performance To 11 On The iPhone
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
 
Tuffarsi in vim
Tuffarsi in vimTuffarsi in vim
Tuffarsi in vim
 
Get Soaked - An In Depth Look At PHP Streams
Get Soaked - An In Depth Look At PHP StreamsGet Soaked - An In Depth Look At PHP Streams
Get Soaked - An In Depth Look At PHP Streams
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scala
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
 
Gashuku Presen
Gashuku PresenGashuku Presen
Gashuku Presen
 
Gashuku Presen
Gashuku PresenGashuku Presen
Gashuku Presen
 
Vim再入門
Vim再入門Vim再入門
Vim再入門
 
A Toda Maquina Con Ruby on Rails
A Toda Maquina Con Ruby on RailsA Toda Maquina Con Ruby on Rails
A Toda Maquina Con Ruby on Rails
 
Scalalable Language for a Scalable Web
Scalalable Language for a Scalable WebScalalable Language for a Scalable Web
Scalalable Language for a Scalable Web
 
Start Vim script @Ujihisa.vim 2011/11/19
Start Vim script @Ujihisa.vim 2011/11/19Start Vim script @Ujihisa.vim 2011/11/19
Start Vim script @Ujihisa.vim 2011/11/19
 
week5_giveup_pwn.pdf
week5_giveup_pwn.pdfweek5_giveup_pwn.pdf
week5_giveup_pwn.pdf
 

Más de cohama (8)

Vim の話
Vim の話Vim の話
Vim の話
 
2016 04-15 nl-nagoya_vim8
2016 04-15 nl-nagoya_vim82016 04-15 nl-nagoya_vim8
2016 04-15 nl-nagoya_vim8
 
2015 12-04 about_neovim
2015 12-04 about_neovim2015 12-04 about_neovim
2015 12-04 about_neovim
 
2014 12-06 ngk2014-b_2014年のvim
2014 12-06 ngk2014-b_2014年のvim2014 12-06 ngk2014-b_2014年のvim
2014 12-06 ngk2014-b_2014年のvim
 
How to use git from vim @vim conf2013
How to use git from vim @vim conf2013How to use git from vim @vim conf2013
How to use git from vim @vim conf2013
 
(初心者向け) Vim の機能紹介@nagoya.vim #1
(初心者向け) Vim の機能紹介@nagoya.vim #1(初心者向け) Vim の機能紹介@nagoya.vim #1
(初心者向け) Vim の機能紹介@nagoya.vim #1
 
Vim script と vimrc の正しい書き方@nagoya.vim #1
Vim script と vimrc の正しい書き方@nagoya.vim #1Vim script と vimrc の正しい書き方@nagoya.vim #1
Vim script と vimrc の正しい書き方@nagoya.vim #1
 
すごいVimでhaskellを書こう@なごやまつり
すごいVimでhaskellを書こう@なごやまつりすごいVimでhaskellを書こう@なごやまつり
すごいVimでhaskellを書こう@なごやまつり
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Auto closing parenthesis @vim conf2014