我正在处理巨大的遗留代码并将Vim视为代码格式化程序。
我可以实现以下目标:
如果有办法,请告诉我..
答案 0 :(得分:3)
您可以查看一下:How change all uppercase words to lowercase, but exclude string literals in Vim
建议的解决方案是:
:%s/\%(^\%([^']*'[^']*'\)*\)\@<=[^']\+/\=substitute(submatch(0),'\<\u\+\>','\L&','g')/g
另一个有用的链接: http://www.linux.com/learn/tutorials/8255-vim-tips-the-basics-of-search-and-replace
答案 1 :(得分:2)
NAG Fortran Compiler附带一个集成的漂亮打印机:
> cat foo.f90 && nagfor =polish -idcase=L -kwcase=L -margin=0 -noblank_line_after_decls -width=80 foo.f90 && cat foo.f90_pol
PROGRAM P
INTEGER :: I
INTEGER :: THIS_INTEGER_VARIABLE_HAS_A_REALLY_LONG_NAME
PRINT *, 'IS THIS THING ON?'
I = THIS_INTEGER_VARIABLE_HAS_A_REALLY_LONG_NAME * THIS_INTEGER_VARIABLE_HAS_A_REALLY_LONG_NAME
END PROGRAM P
NAG Fortran Polisher Release 6.0(Hibiya) Build 1037
[NAG Fortran Polisher normal termination]
program p
integer :: i
integer :: this_integer_variable_has_a_really_long_name
print *, 'IS THIS THING ON?'
i = this_integer_variable_has_a_really_long_name* &
this_integer_variable_has_a_really_long_name
end program p
(披露:我为NAG工作。)