简体   繁体   English

Vimrc函数清理当前行

[英]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. 我正在尝试创建一个vimrc函数,该函数将通过执行简单的替换来清理一行。 The function is called upon CARRIAGE RETURN. 在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() 有一个名为setline()的函数

Type :help setline() for help. 输入:help setline()获得帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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