Code Monkey home page Code Monkey logo

xalign's Introduction

XAlign (Ready for Xcode 8+ 🚀)

An amazing Xcode Source Editor extension to align regular code. It can align anything by using custom alignment patterns.

What's XAlign

Here are some example alignment patterns. Of course you can make your own. The pattern file is here: /Source/Patterns.bundle/default.plist, and the patterns are based on regular expression.

Tips:

  • You may not like the alignment style below, try it yourself or tell me at the Issues. :)
  • There is no need to align all codes at a time when they are complicated, try to align by group which the codes are more similar in.
  • 对齐不需要一次全部对齐,可以分组多对几次,那些等号差的太远的就别让它参与对齐了。
  • 默认对齐的风格不是你喜欢的,可以自定义,或者提个 Issues

Align by equals sign

Equal

Align by define group

Define

Align by property group

Property

Todo:

  • Much easier to customize alignment patterns.

Install on Xcode 8

  1. Download the XAlign.dmg📎 or XAlign.app.zip📎
  2. Open and copy XAlign.app to /Applications folder
  3. Run it then close it.

Usage

1. Enable XAlign

Check System Preferences -> Extensions -> Xocde Source Editor -> XAlign

help-1

2. Setting Shortcut in Xocde

Preferences -> Key bindings -> Filter: xalign

help-2

Trouble Shooting

  • Please install macOS Sierra (version 10.12) if your macOS is 10.11.
  • If you are looking for the version supporting Xcode 7, check this branch;

Want to help

Special thanks to

  • Geek Zoo Studio Geek Zoo Studio

    They provide awesome design and development works continues to help the open-source community even better.

  • BeeFramework

    BeeFramework is a new generation of development framework which makes faster and easier app development, Build your app by geek's way.

xalign's People

Contributors

bre7 avatar gabibbocode avatar jiehu5114 avatar levey avatar phatmann avatar qfish avatar rbbtsn0w avatar tomnaz avatar watanareborn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xalign's Issues

define的排列有点问题

比如

#define AALocalizedString(key) [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]
#define AAColorWithRGBA(R, G, B, A) [UIColor colorWithRed:(R)/255.0 green:(G)/255.0 blue:(B)/255.0 alpha:A]

按照define排列后回变成这样

#define AALocalizedString(key) [[NSBundle mainBundle] localizedStringForKey:(key) value:@""        table:nil]
#define AAColorWithRGBA(R, G, B, A) [UIColor colorWithRed:(R)/255.0 green:(G)/255.0 blue:(B)/255.0 alpha:A]

多出一些空格。

注释怎么对齐

现在的对齐效果如下,我想要注释能对齐
对其前

@property(nonatomic, readonly)NSString *abcde; // 属性abcde
@property(nonatomic, readonly)NSString *bcde; // 属性bcde
@property(nonatomic, strong)NSString *cde;           // 属性cde
@property(nonatomic, readonly)NSArray *de;         // 属性de
@property(nonatomic, strong)NSDictionary *e; // 属性e
@property(nonatomic, weak, readonly)id delegate;         // 属性delegate

对齐后

@property (nonatomic, readonly      ) NSString     *abcde;// 属性abcde
@property (nonatomic, readonly      ) NSString     *bcde;// 属性bcde
@property (nonatomic, strong        ) NSString     *cde;// 属性cde
@property (nonatomic, readonly      ) NSArray      *de;// 属性de
@property (nonatomic, strong        ) NSDictionary *e;// 属性e
@property (nonatomic, weak, readonly) id           delegate;// 属性delegate

Align by colons?

Hi. Thanks for the great plugin.

With Swift being proliferated with colons (:) is there any chance of this becoming an alignment option?

Xcode beta

I just wanted to know how to install in the Xcode Beta. When I installed, it only appeared in normal xcode

Not working with Xcode 5.1

I saw the plug-in under that plug-ins folder, and restarted xcode like several times, also i replaced the plug-in again, none of them is working

Xcode5.1安装后启动就崩溃

Process: Xcode [706]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 5.1.1 (5085)
Build Info: IDEFrameworks-5085000000000000~10
Code Type: X86-64 (Native)
Parent Process: launchd [140]
User ID: 504

Date/Time: 2014-04-19 11:46:58.722 +0800
OS Version: Mac OS X 10.8.4 (12E55)
Report Version: 10

Interval Since Last Report: 1671278 sec
Crashes Since Last Report: 37
Per-App Interval Since Last Report: 283 sec
Per-App Crashes Since Last Report: 6
Anonymous UUID: 7946710D-59ED-68CD-4448-9133643A5729

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000018

VM Regions Near 0x18:
-->
__TEXT 000000010f4ca000-000000010f4cb000 [ 4K] r-x/rwx SM=COW /Applications/Xcode.app/Contents/MacOS/Xcode

Application Specific Information:
ProductBuildVersion: 5B1008

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x00007fff8e9d9498 objc_msgSend_vtable3 + 24
1 com.apple.Foundation 0x00007fff93c8e307 -[NSBundle loadAndReturnError:] + 646
2 com.apple.Foundation 0x00007fff93c8e07c -[NSBundle load] + 19
3 com.apple.Xcode.DevToolsCore 0x0000000115657c10 -[XCPluginManager loadPluginBundle:] + 479
4 com.apple.Xcode.DevToolsCore 0x0000000115657617 -[XCPluginManager findAndLoadPluginsInDomain:] + 4302
5 com.apple.Xcode.DevToolsCore 0x000000011561aa88 XCInitializeCoreIfNeeded + 4247
6 com.apple.dt.IDE.Xcode3Core 0x00000001154da270 +[Xcode3CoreInitializer ide_initializeWithOptions:error:] + 16
7 com.apple.dt.IDEFoundation 0x000000011007a989 _IDEInitializeOnePlugInAndPrerequisites + 1359
8 com.apple.dt.IDEFoundation 0x000000011007a066 _IDEInitializePlugIns + 980
9 com.apple.dt.IDEFoundation 0x0000000110079b55 __IDEInitialize_block_invoke + 42
10 com.apple.dt.IDEFoundation 0x000000011007a270 IDESetSafeToLoadMobileDevice + 203
11 com.apple.dt.IDEKit 0x0000000110600f04 -[IDEWelcomeWindowController _showFirstLaunchExperienceIfAppropriate] + 316
12 com.apple.dt.IDEKit 0x0000000110600dab -[IDEWelcomeWindowController openWelcomeWindowAfterFirstLaunchExperienceIfAppropriate:] + 29
13 com.apple.dt.IDEKit 0x0000000110600cd7 -[IDEApplicationController applicationOpenUntitledFile:] + 230
14 com.apple.AppKit 0x00007fff94a91c34 -[NSApplication _doOpenUntitled] + 482
15 com.apple.AppKit 0x00007fff94a916cf __58-[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:]_block_invoke_0 + 233
16 com.apple.AppKit 0x00007fff94dd36c1 __78-[NSDocumentController(NSInternal) _autoreopenDocumentsWithCompletionHandler:]_block_invoke_01437 + 143
17 com.apple.AppKit 0x00007fff94a9117b -[NSDocumentController(NSInternal) _autoreopenDocumentsWithCompletionHandler:] + 760
18 com.apple.AppKit 0x00007fff94a8f66e -[NSApplication reopenWindowsAsNecessaryIncludingRestorableState:registeringAsReady:completionHandler:] + 298
19 com.apple.AppKit 0x00007fff94a8f445 -[NSApplication(NSAppleEventHandling) handleAEOpenEvent:] + 553
20 com.apple.AppKit 0x00007fff94a8f04c -[NSApplication(NSAppleEventHandling) handleCoreEvent:withReplyEvent:] + 351
21 com.apple.Foundation 0x00007fff93c7c07b -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 308
22 com.apple.Foundation 0x00007fff93c7bedd NSAppleEventManagerGenericHandler + 106
23 com.apple.AE 0x00007fff99031078 aeDispatchAppleEvent(AEDesc const
, AEDesc
, unsigned int, unsigned char
) + 307
24 com.apple.AE 0x00007fff99030ed9 dispatchEventAndSendReply(AEDesc const
, AEDesc*) + 37
25 com.apple.AE 0x00007fff99030d99 aeProcessAppleEvent + 318
26 com.apple.HIToolbox 0x00007fff976e0709 AEProcessAppleEvent + 100
27 com.apple.AppKit 0x00007fff94a8b836 _DPSNextEvent + 1456
28 com.apple.AppKit 0x00007fff94a8adf2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
29 com.apple.dt.DVTKit 0x000000010fbc2631 -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 84
30 com.apple.AppKit 0x00007fff94a821a3 -[NSApplication run] + 517
31 com.apple.AppKit 0x00007fff94a26bd6 NSApplicationMain + 869
32 libdyld.dylib 0x00007fff9a0bd7e1 start + 1

分號

我想要連分號也對齊可以嗎?類似這樣

@Property (strong, nonatomic) UIWindow *window ;
@Property (strong, nonatomic) UINavigationController *navController ;
@Property (strong, nonatomic) ViewController *viewController ;

@Property (strong, nonatomic) NSString *deviceToken ;
@Property (strong, nonatomic) NSString *urlToUpgrade ;
@Property ( nonatomic) bool shouldAlertOnce ;
@Property ( nonatomic) bool shouldAlertAlways ;
@Property ( nonatomic) bool shouldQuit ;
@Property ( nonatomic) bool isHideStatusBar ;

The plugin dissapear from menu

I've installed it using http://alcatraz.io/ but although it recognize that XAlign it's installed, neither the shortcut neither the menu option are available, so i have to reinstall it again untill it disappears again.

Using XCode 5 and the shortcut isn't overrided by anyother plugin or fucntion.

Xcode6.1.1 编译XAlign报错

下载XAlign后build,报错:
ld: can't write output file: /Users/jason/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XAlign.xcplugin/Contents/MacOS/XAlign for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: couldn't remove '/Users/jason/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XAlign.xcplugin/Contents/MacOS/XAlign' after command failed: Permission denied

安装后重启Xcode未生效

首先非常感谢qfish的贡献。

安装后未生效:

环境:10.8.5 Xcode 4.6.3

使用手动和命令2种方式都试过,~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/下已存在插件,重启Xcode未出现Edit-> XAlign,卸载后重新安装也不行

Incorrect formatting for URL strings

With any URL string that is statically defined at the top of my file, when aligned with other strings or numbers, it inserts a whitespace between the colon and forward slashes.

Before

static NSString *const PVideoAPIURLString = @"http://10.61.32.63/v1/";

static NSString *const PUserContextUserId = @"Present-User-Context-User-Id";
static NSString *const PUserContextSessionToken = @"Present-User-Context-Session-Token";

After:

static NSString *const PVideoAPIURLString       = @"http: //10.61.32.63/v1/";

static NSString *const PUserContextUserId       = @"Present-User-Context-User-Id";
static NSString *const PUserContextSessionToken = @"Present-User-Context-Session-Token";

property

property name 跟指標 ( * ) 可以不要空格嗎

目前 align 後, 例如

@Property (strong, nonatomic) NSMutableArray * dataSource;

dataSource 跟指標間會有空格, 大家應該習慣沒空格吧

Xcode6.3.2 OS X10.10.3 安装失败

使用命令行,手动复制文件到插件路径,Alcatraz均失败。
在Edit菜单没有看见XAlign,快捷键也没反应。
卸载重装还是没看到有。其他插件均正常。

Define Group加了注释之后对齐有问题

比如

#define message_reply_me             L(@"message_reply_me")                  //回复我的";
#define message_at_me             L(@"message_at_me")                     //@我的";
#define message_at_me_topic             L(@"message_at_me_topic")                //主帖";
#define message_at_me_reply             L(@"message_at_me_reply")                     //回复";

对齐的时候只会对齐注释

Aligned text block introduces extra newlines.

When I apply the align command on the following block:

  const API::Resource::Key Version = API::Resource::Key::Generate("Core::Version");
  const API::Resource::Key ProductName = API::Resource::Key::Generate("Core::ProductName");
  const API::Resource::Key AuthorName = API::Resource::Key::Generate("Core::AuthorName");
  const API::Resource::Key OrganisationName = API::Resource::Key::Generate("Core::OrganisationName");

The resulting aligned block will have extra newlines inserted:

  const API::Resource::Key Version          = API::Resource::Key::Generate("Core::Version");

  const API::Resource::Key ProductName      = API::Resource::Key::Generate("Core::ProductName");

  const API::Resource::Key AuthorName       = API::Resource::Key::Generate("Core::AuthorName");

  const API::Resource::Key OrganisationName = API::Resource::Key::Generate("Core::OrganisationName");

The source file in question is in UTF-8 format, with Windows (CRLF) encoding.

Dont force space after *

I prefer to use the syntax NSString *foo rather than NSString * foo. You should keep whatever syntax style preference the user has already when manipulating the text.

Swift

This plugin does nothing with a Swift file .

Feature request: Dictionary literal supports

  // before
  return @{@"name": @"张三",
           @"age": @"30",
           @"qq": @"12345",
           @"id": @"123456789012345678",
           @"customKey": @"value",
           @"LongLongLongLongLongLongLongLongKey": @"value"};

  // after
  return @{@"name"                   : @"张三",
           @"age"                    : @"30",
           @"qq"                     : @"12345",
           @"id"                     : @"123456789012345678",
           @"customKey"              : @"value",
           @"LongLongLongLongLongKey": @"value"};

  // after
  return @{@"name"     : @"张三",
           @"age"      : @"30",
           @"qq"       : @"12345",
           @"id"       : @"123456789012345678",
           @"customKey": @"value",
           @"LongLongLongLongLongKey": @"value"};

没有插件制作经验,看了下源码,没有详细的自定义文档无法自己动手自定义,希望能够完善下相关文档。顺便有时间可以考虑实现下此功能,和等号一样可以分段对齐。谢谢。

Installing in Xcode 6.2b3 ... Tango Uniform... Breaks Alcatraz Too

Using Alcatraz to install produced empty Package (repeated tries, same result):

xalign_xcplugin

Installing using
curl http://qfi.sh/XAlign/build/install.sh | sh
installs full plugin but the plug in fails to activate and neither can be invoked via command key nor appears in menu. Installation, for some reason, requires admin privileges?

Removing XAlign.xcplugin from the Xcode plug ins folder by deleting in the Finder requires admin privileges (?) and afterwards, Alcatraz will fail to perform an install of the same plugin.

Putting XAlign.xcplugin back into the Xcode plug ins folder requires admin privileges (something amiss with the XAlign.xcplugin package guts..).

Uninstalling XAlign.xcplugin using the uninstall command provided by the developer:
curl http://qfi.sh/XAlign/build/uninstall.sh | sh
uninstalls the plug in.

After uninstalling XAlign.xcplugin, Alcatraz is broken. Alcatraz's controls all work except the install / uninstall buttons. Quitting and re-running Xcode does not fix Alcatraz.

Removing Alcatraz's cached data using:
rm -rf ~/Library/Application\ Support/Alcatraz
does not restore Alcatraz to an operational state.

Removing Alcatraz in the Finder (or using the 'rm' command, same thing), then reinstalling using:
curl -fsSL https://raw.github.com/supermarin/Alcatraz/master/Scripts/install.sh | sh
does not bring Alcatraz back to operation. Alcatraz's window will open but no install "buttons" work. All other controls still work in the Alcatraz window short of the install buttons to the left of each plugin (etc) listed.

Starting to have serious concerns about the install of XAlign including and especially the need for admin privileges to install it... How (why?) did it manage to only break Alcatraz's ability to install / uninstall.

快捷键不能使用了

我换了好多种快捷键,全部没有反应,使用不了,每次要对齐都要去菜单那里一层层选进去好麻烦

Xcode6不支持吗

我安装重启Xcode后按快捷键无反应
Edit里也没找到菜单

Some line is not aligned. Possibly because text is too long.

The alignment is not working on some line. Possibly because text is too long. In my case the #define DEFAULT_app_home_screen_title @"Hotel" line is not changed somehow. Other lines work fine. See below.

Before:

#define COMPANY_ID 2
#define BRAND_ID @"123"
#define DEFAULT_app_home_screen_title @"Hotel"
#define PROPERTY_ID @"123"

After:

#define COMPANY_ID                            2
#define BRAND_ID                              @"123"
#define DEFAULT_app_home_screen_title @"Hotel"
#define PROPERTY_ID                           @"123"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.