-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tabular resets the cursor position to the beginning of the line #31
Comments
Okay, I've been investigating this, and it might be a vim bug. I ran the function with
|
Basically, it should do what tpope does at https://gist.github.com/tpope/287147 |
I'm seeing the same issue while I'm typing. For example, when I'm typing the second delimiter in my config file:
...as soon as I complete the delimiter my cursor zooms back to column one!
My vim config:
|
@table-delete In case you never figured it out: I'm pretty sure you're using rodjek's vim-puppet like me. I'm not sure whether tabular or vim-puppet is responsible for this bug, but a workaround is to turn off automatic hash alignment in vim-puppet by |
This is old, but I though I'd weigh in. If you're doing INSERT mappings, deciding where to position the cursor after triggering Tabularize requires you to make some assumptions about what sort of input you're typing. The author of Tabularize can't make those assumptions for you. If you look at tpope's script, you can see it checks which column the cursor was in before doing the Tabularize, and then moves the cursor to the right place afterwards. For 'fat-arrow' separated key-value pairs (as seen in Perl and PHP) I wrote this function. This should behave how you expect for most cases. function! s:PairUp()
if getline('.')[ col('.') - 2 ] == '='
Tabularize /=>
normal! 0
silent! echo searchpos('=>')
call cursor( line('.'), col('.') + 1 )
endif
endfunction
inoremap <silent>> ><Esc>:call <SID>PairUp()<CR>a I'm not a vimscript expert so there might be a better way to acheive this, but for those interested, here's the rundown. I've set my function to trigger on The function looks at the character you typed just before Make sure you put an EDIT if getline('.')[ col('.') - 3 : col('.') - 1 ] =~ '\s=>' This looks at the 3 characters before the cursor and confirms they are a whitespace character followed by |
After running :Tabularize, the cursor is at the beginning of the line.
It would be nice if it was in the same logical position, so that running :Tabularize /= on
becomes
with the cursor being on C in both cases. I hope you can understand what I mean.
The text was updated successfully, but these errors were encountered: