[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

python3-ly reformat in vim

From: Andrew Bernard
Subject: python3-ly reformat in vim
Date: Fri, 10 May 2019 13:08:57 +1000

For those who use vim, I'm posting this as result of my discovery of python3-ly reformat thanks to David Wright in the hope that others may find it useful.

This is for Debian or Ubuntu, and assumes the Python package python3-ly is installed.

Add this code to ~/.vimrc:

" lilypond reformat (acb)
" reformat buffer, and return cursor to about the same place.
fun DoLilypondReformat()
    let l = line(".")
    let c = col(".")
    :%!ly reformat
    call cursor(l, c)

au Filetype lilypond nmap <F2> :call DoLilypondReformat()<CR>

Pressing F2 will reformat the current buffer. Note that, as with all code tidying programs, you can only return the cursor to approximately the same position, as lines may be added of deleted. But better than nothing. Without that repositioning code, the cursor is repositioned at line 1 after a filter operation in vim.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]