I'm having some trouble with vim, gg=G doesn't remove extra newlines, I'm trying with
:%s/\(\n\)\n\+/\1/g
but it's not working in the whole file. Any help appr开发者_Go百科eciated.
This should work in vim
...
:g/^\s*$/d
" Put the function bellow in your vimrc
" remove extra newlines keeping the cursor position and search registers
fun! DelBlank()
let _s=@/
let l = line(".")
let c = col(".")
:g/^\n\{2,}/d
let @/=_s
call cursor(l, c)
endfun
" the function can be called with "leader" d see :h <leader>
map <special> <leader>d :keepjumps call DelBlank()<cr>
精彩评论