-
Notifications
You must be signed in to change notification settings - Fork 121
Open
Description
This is not really an issue, but rather a function that I wrote to mimic this but by using this plugin.
vim9script
export def Align()
const p = '^\s*|\s*.*\s*|\s*$'
if exists(':EasyAlign') != 0 && getline('.') =~# '^\s*|'
# Save column and position
const curpos = getcursorcharpos()
# Search for first line
var startline = line('.')
if startline != 1
while getline(startline - 1) =~ p
startline = search(p, 'bW')
endwhile
endif
setcursorcharpos(curpos[1], curpos[2])
# Search for last line
var endline = line('.')
if endline != line('$')
while getline(endline + 1) =~ p
endline = search(p, 'W')
endwhile
endif
setcursorcharpos(curpos[1], curpos[2])
# Easy align
execute $":{startline},{endline}EasyAlign *|"
setcursorcharpos(curpos[1], strchars(getline(curpos[1])))
endif
enddef
inoremap <silent> <Bar> <Bar><Esc><ScriptCmd>Align()<CR>aHope you find it useful!
junegunn
Metadata
Metadata
Assignees
Labels
No labels