让 Vim 花括号、方括号、Parens 像 Textmate 一样 [英] Make Vim Curly Braces, Square Braces, Parens act like Textmate

查看:37
本文介绍了让 Vim 花括号、方括号、Parens 像 Textmate 一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想我不是在寻找正确的东西,但我想看看在编写一组花括号、括号或方括号时,如何让 VIM 像 Textmate 一样按 Enter 键和你明白了.管道表示光标.

So I guess I'm not searching for the right thing but I'm looking to see how you can get VIM to act like Textmate when it comes to writing a set of curly braces, parens, or square brackets hit enter and you get this. Pipe indicates cursor.

      function doSomething(){
          |
      }

      #selector{
          |
      }

代替这个垃圾

      function doSomething(){
      |}

      #selector{
      |}

我已经有了 [{( 在输入时彼此关闭,只是返回和缩进被顶起.像往常一样,任何帮助将不胜感激.

I already have the [{( closing each other when they are typed just the return and indentation is jacked. As usual any help would be appreciated.

推荐答案

我在我的 .vimrc 中使用以下映射:

I use the following mappings in my .vimrc:

inoremap {<cr> {<cr>}<c-o>O<tab>
inoremap [<cr> [<cr>]<c-o>O<tab>
inoremap (<cr> (<cr>)<c-o>O<tab>

所以当我输入:

function foo(){<cr>

我明白了:

function foo(){
    |
}

([ 类似.

这篇关于让 Vim 花括号、方括号、Parens 像 Textmate 一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆