Created
May 24, 2014 16:28
-
-
Save Soft/741b7b6c32ceebb4bcb5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! AlignAssignments() range | |
let l:max = -1 | |
for n in range(a:firstline, a:lastline) | |
let l:line = getline(n) | |
let l:pos = match(line, "=") | |
if pos > max | |
let l:max = pos | |
endif | |
endfor | |
for n in range(a:firstline, a:lastline) | |
let l:line = getline(n) | |
let l:pos = match(line, "=") | |
if pos > -1 | |
let l:diff = l:max - l:pos | |
execute "normal! " . n . "gg0" . pos . "li" . repeat(" ", l:diff) . "\<esc>" | |
endif | |
endfor | |
endfunction | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment