开发者

Vim indenting and alignment: combining spaces and tabs

开发者 https://www.devze.com 2023-03-16 07:49 出处:网络
I\'m trying to work out how to get Vim to follow a slightly more complex indentation scheme than most editors allow by default. Essentially I want to use tabs for indentation, but spaces to align stat

I'm trying to work out how to get Vim to follow a slightly more complex indentation scheme than most editors allow by default. Essentially I want to use tabs for indentation, but spaces to align statements that span more than one line. For example:

    private static $_columns = array('id' => 'id',
                                     'email' => 'email',
                                     'pas开发者_运维知识库swordHash' => 'password_hash',
                                     'salt' => 'salt');
    ^ tabs up to here
                                     ^ spaces up to here

The idea here is that indentation follows the tab-width preferences of whoever is editing the file, while multi-line statements still align correctly.

I guess the simple way to implement this would be to have Vim just copy the indentation pattern used on the previous line (i.e. the leading white space) whenever a new line is entered. Is there any way to do this in Vim? Would I need to write a plugin?


There is a wikia entry dedicated to that topic : Indent with tabs, align with spaces

The suggested solution is to use a plugin : "Smart Tabs"

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号