Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Can I disable auto-pairs for certain characters? #29

Closed
Goles opened this Issue Dec 23, 2012 · 18 comments

Comments

Projects
None yet
3 participants

Goles commented Dec 23, 2012

I use vim for Objective-C programming... I was wondering if auto-pairs can be disabled for the [ and ] characters.

Cheers and thanks for this plug-in 👍

Contributor

halftan commented Dec 23, 2012

set g:AutoPairs to what ever you want
the default is:

{'(':')', '[':']', '{':'}',"'":"'",'"':'"', '':''}

for more options read the readme file at github webpage
https://github.com/jiangmiao/auto-pairs

2012/12/23 Nicolas Goles notifications@github.com

I use vim for Objective-C programming... I was wondering if auto-pairs
can be disabled for the [ and ] characters.

Cheers and thanks for this plug-in [image: 👍]


Reply to this email directly or view it on GitHubhttps://github.com/jiangmiao/auto-pairs/issues/29.

Goles commented Dec 23, 2012

I read about it and tried:

let g:AutoPairs {'(':')','{':'}',"'":"'",'"':'"', '`':'`'}

But resulted in error, what's the correct syntax to do this ?

Contributor

halftan commented Dec 23, 2012

the '=' will cry :<

2012/12/23 Nicolas Goles notifications@github.com

I read about it and tried:

let g:AutoPairs {'(':')','{':'}',"'":"'",'"':'"', '':''}

But resulted in error, what's the correct syntax to do this ?


Reply to this email directly or view it on GitHubhttps://github.com/jiangmiao/auto-pairs/issues/29#issuecomment-11646848.

Goles commented Dec 23, 2012

Cool!!

Since the aforementioned setting is only for objc and objcpp, can I somehow enable g:AutoPairs for certain filetypes ? ( I would like to keep [ and ] for editing C or C++.

Contributor

halftan commented Dec 23, 2012

So take a look at this

if &filetype == "html" || &filetype == "htm" || &filetype == "eruby"

let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '':'',
'<':'>'}

endif

i use this for editing html and rails erb, this will also help you with
your objc

2012/12/23 Nicolas Goles notifications@github.com

Cool!!

Since the aforementioned setting is only for objc and objcpp, can I
somehow enable g:AutoPairs for certain filetypes ? ( I would like to keep
[ and ] for editing C or C++.


Reply to this email directly or view it on GitHubhttps://github.com/jiangmiao/auto-pairs/issues/29#issuecomment-11647044.

Goles commented Dec 23, 2012

I think that will work if I edit my file by doing vim MyFile.m , but my workflow uses lot's of buffer switching...

usually I vim into a project folder:

vim

and then use a plugin like ctrlp to navigate through the files I want to edit... in this case the &filetype == "objc" won't work...

( Maybe I'm wrong though )

Cheers!

Contributor

halftan commented Dec 23, 2012

Well, since I use NerdTree + vim-nerdtree-tab, the &ft changes when I
switch to another file/buffer.
It'll also work on Mac.

2012/12/23 Nicolas Goles notifications@github.com

I think that will work if I edit my file by doing vim MyFile.m , but my
workflow uses lot's of buffer switching...

usually I vim into a project folder:

vim

and then use a plugin like ctrlp to navigate through the files I want to
edit... in this case the &filetype == "objc" won't work...

( Maybe I'm wrong though )

Cheers!


Reply to this email directly or view it on GitHubhttps://github.com/jiangmiao/auto-pairs/issues/29#issuecomment-11647136.

Goles commented Dec 23, 2012

Hmm so the fix would be to switch to NerdTree? Don't really like NerdTree... would love if there was another way to solve this...

I think that the issue is not related to filetype changes, but to buffer switching.

Maybe to make this work on any buffer (after the first) it would be better suited as an ftplugin ?

Contributor

halftan commented Dec 23, 2012

I really don't know about that plugin you use but I tested ft in a bare vim
install by switching to different files and type :echo &ft.
That really works. It returns haml when I'm in an haml buffer an ruby in a
ruby file.

2012/12/23 Nicolas Goles notifications@github.com

Hmm so the fix would be to switch to NerdTree? Don't really like NerdTree...
would love if there was another way to solve this...

I think that the issue is not related to filetype changes, but to buffer
switching.

Maybe to make this work on any buffer (after the first) it would be better
suites as an ftplugin ?


Reply to this email directly or view it on GitHubhttps://github.com/jiangmiao/auto-pairs/issues/29#issuecomment-11647287.

Contributor

halftan commented Dec 23, 2012

Well.... different buffers I mean.

2012/12/23 Andy Zhang half.a.tan@gmail.com

I really don't know about that plugin you use but I tested ft in a bare
vim install by switching to different files and type :echo &ft.
That really works. It returns haml when I'm in an haml buffer an ruby in
a ruby file.

2012/12/23 Nicolas Goles notifications@github.com

Hmm so the fix would be to switch to NerdTree? Don't really like NerdTree...
would love if there was another way to solve this...

I think that the issue is not related to filetype changes, but to buffer
switching.

Maybe to make this work on any buffer (after the first) it would be
better suites as an ftplugin ?


Reply to this email directly or view it on GitHubhttps://github.com/jiangmiao/auto-pairs/issues/29#issuecomment-11647287.

Goles commented Dec 23, 2012

If you have a minute you can check out ctrlp, maybe you'll even like it, if you have a minute of course :)

Cheers!

Contributor

halftan commented Dec 23, 2012

That was really awesome a plugin. I will probably close vim and switch
to sublime
text 2 when working on a project and it has the function what ctrlp
provides.
Anyway, I think no matter what plugin you use, the &filetype always works
because it's implemented by vim's base code and will be refreshed once you
switch to another buffer/file. Hmm, maybe I'll test again after installing
ctrlp.

2012/12/24 Nicolas Goles notifications@github.com

If you have a minute you can check out ctrlphttp://kien.github.com/ctrlp.vim/,
maybe you'll even like it, if you have a minute of course :)

Cheers!


Reply to this email directly or view it on GitHubhttps://github.com/jiangmiao/auto-pairs/issues/29#issuecomment-11647356.

Owner

jiangmiao commented Dec 23, 2012

Thank you halftan for answering.

g:AutoPairs is global variable.
I will add a buffer level controlling.

Contributor

halftan commented Dec 23, 2012

正好在线而已,而且我还从来没有收到过关于这个插件的邮件呢。
单个buffer控制会很麻烦的吧?不管是rc里设置还是输入命令。直接用&ft不是更好么?

Will it be a trouble to config for each buffer either through .vimrc or
command? I think it's better to play with &ft and it will be more flexible.

2012/12/24 Miao Jiang notifications@github.com

Thank you halftan for answering.

g:AutoPairs is global variable.
I will add a buffer level controlling.


Reply to this email directly or view it on GitHubhttps://github.com/jiangmiao/auto-pairs/issues/29#issuecomment-11647621.

Contributor

halftan commented Dec 23, 2012

Alright, I've tested the &ft with ctrlp plugin and it works well. @nicolas
you can go with it.

2012/12/24 Andy Zhang half.a.tan@gmail.com

正好在线而已,而且我还从来没有收到过关于这个插件的邮件呢。
单个buffer控制会很麻烦的吧?不管是rc里设置还是输入命令。直接用&ft不是更好么?

Will it be a trouble to config for each buffer either through .vimrc or
command? I think it's better to play with &ft and it will be more
flexible.

2012/12/24 Miao Jiang notifications@github.com

Thank you halftan for answering.

g:AutoPairs is global variable.
I will add a buffer level controlling.


Reply to this email directly or view it on GitHubhttps://github.com/jiangmiao/auto-pairs/issues/29#issuecomment-11647621.

Owner

jiangmiao commented Dec 23, 2012

add

au Filetype FILETYPE let b:AutoPairs = {'(':')','{':'}',"'":"'",'"':'"', '`':'`'}

to .vimrc

modify FILETYPE to the ft maybe objc to let objc file only match {'(':')','{':'}',"'":"'",'"':'"', '':''}

Owner

jiangmiao commented Dec 23, 2012

单个还行 在进入buffer时确认一下b:AutoPairs,如果为空就设为g:AutoPairs,如果不为空就为以b:AutoPairs为准。
你的方法应该不断的检测 ft 进行设置,每次在BufEnter时就通过ft改变g:AutoPairs的确也行。

Goles commented Dec 23, 2012

Awesome!!

Thanks!

@Goles Goles closed this Dec 23, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment