简体   繁体   中英

Vimrc function to clean up current line

I am trying to create a vimrc function which will clean up a line by doing simple substitutions. The function is called upon CARRIAGE RETURN. The function is being called and is cleaning up the line contents. My question is how do I overwrite the previous content with the cleaned up content from inside the function?

function! CleanLine()
  let s = getline( '.' )
  let s = substitute( s, '( )', '()', 'g' )
  let s = substitute( s, ';', '; ', 'g' )
  let s = substitute( s, '(', ' (', 'g' )
  "HOW DO I SET THE CURRENT LINE CONTENT AS s
endfunction
inoremap <CR> <C-R>=CleanLine()<CR>

thanks.

There is a function called setline()

Type :help setline() for help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM