[求助]vim怎样首字母大写?
-
- 帖子: 513
- 注册时间: 2009-11-30 7:46
[求助]vim怎样首字母大写?
如题。。。。
-
- 帖子: 54
- 注册时间: 2008-03-12 14:33
Re: [求助]vim怎样首字母大写?
试试这个,选中文字用~转换。
代码: 全选
"" Twiddle case {{{
function! TwiddleCase(str)
if a:str ==# toupper(a:str)
let result = tolower(a:str)
elseif a:str ==# tolower(a:str)
let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g')
else
let result = toupper(a:str)
endif
return result
endfunction
vnoremap ~ ygv"=TwiddleCase(@")<CR>Pgv
" }}}
操作系统:Linux erocpil 2.6.38-gentoo-r6 #2 SMP Sun Sep 11 10:15:16 GMT 2011 x86_64 Intel(R) Core(TM)2 CPU T5200 @ 1.60GHz GenuineIntel GNU/Linux
编程语言:C/C++,Perl。
谷歌代码:manshow-重新编译的win32版本Vim,加入诸多特性:非等宽中文字体(如微软雅黑),脚本语言接口(如Perl,Python,Lua),透明效果等。
个人主页:http://lyx.us.tc/
编程语言:C/C++,Perl。
谷歌代码:manshow-重新编译的win32版本Vim,加入诸多特性:非等宽中文字体(如微软雅黑),脚本语言接口(如Perl,Python,Lua),透明效果等。
个人主页:http://lyx.us.tc/
- lilydjwg
- 论坛版主
- 帖子: 4258
- 注册时间: 2009-04-11 23:46
- 系统: Arch Linux
- 联系:
Re: [求助]vim怎样首字母大写?
Vim 手册 写了:代码: 全选
要以标题大写 (title cap) 方式改写一行,亦即使每个单词的首字母大写: > :s/\v<(.)(\w*)/\u\1\L\2/g
-
- 帖子: 750
- 注册时间: 2006-03-19 11:39
Re: [求助]vim怎样首字母大写?
有区别么,vim 里用微软鸦黑还是那么的丑manshow-重新编译的win32版本Vim,加入诸多特性:非等宽中文字体(如微软雅黑),脚本语言接口(如Perl,Python,Lua),透明效果等。

-
- 帖子: 1
- 注册时间: 2011-12-10 13:41
Re: [求助]vim怎样首字母大写?
代码: 全选
s/\v<(.)(\w*)/\u\1\L\2/g
- lilydjwg
- 论坛版主
- 帖子: 4258
- 注册时间: 2009-04-11 23:46
- 系统: Arch Linux
- 联系:
Re: [求助]vim怎样首字母大写?
Don't repeat me.gcy001 写了:帮助里举的例子。代码: 全选
s/\v<(.)(\w*)/\u\1\L\2/g
-
- 帖子: 54
- 注册时间: 2008-03-12 14:33
Re: [求助]vim怎样首字母大写?
你发个不丑的让大家看看。kardinal 写了:有区别么,vim 里用微软鸦黑还是那么的丑manshow-重新编译的win32版本Vim,加入诸多特性:非等宽中文字体(如微软雅黑),脚本语言接口(如Perl,Python,Lua),透明效果等。
操作系统:Linux erocpil 2.6.38-gentoo-r6 #2 SMP Sun Sep 11 10:15:16 GMT 2011 x86_64 Intel(R) Core(TM)2 CPU T5200 @ 1.60GHz GenuineIntel GNU/Linux
编程语言:C/C++,Perl。
谷歌代码:manshow-重新编译的win32版本Vim,加入诸多特性:非等宽中文字体(如微软雅黑),脚本语言接口(如Perl,Python,Lua),透明效果等。
个人主页:http://lyx.us.tc/
编程语言:C/C++,Perl。
谷歌代码:manshow-重新编译的win32版本Vim,加入诸多特性:非等宽中文字体(如微软雅黑),脚本语言接口(如Perl,Python,Lua),透明效果等。
个人主页:http://lyx.us.tc/