/usr/share/vim/cream/cream-capitalization.vim is in cream 0.43-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | "
" cream-capitalization.vim
"
" Cream -- An easy-to-use configuration of the famous Vim text editor
" [ http://cream.sourceforge.net ] Copyright (C) 2001-2011 Steve Hall
"
" License:
" This program is free software; you can redistribute it and/or modify
" it under the terms of the GNU General Public License as published by
" the Free Software Foundation; either version 2 of the License, or
" (at your option) any later version.
" [ http://www.gnu.org/licenses/gpl.html ]
"
" This program is distributed in the hope that it will be useful, but
" WITHOUT ANY WARRANTY; without even the implied warranty of
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
" General Public License for more details.
"
" You should have received a copy of the GNU General Public License
" along with this program; if not, write to the Free Software
" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
" 02111-1307, USA.
"
" Updated: 2003-12-06, 09:36am
" Source: http://vim.sourceforge.net/scripts/script.php?script_id=242
" Author: Steve Hall [ digitect@mindspring.com ]
"
" Instructions:
" o Simply copy this file and paste it into your vimrc. Or you can
" drop the entire file into your plugins directory.
" o As long as you don't already have keyboard mappings to the F5 key,
" these keyboard shortcuts will now be available:
" F5 Capitalize selection, title case
" Shift+F5 Uppercase selection
" Alt+F5 Lowercase selection
" Ctrl+F5 Reverse case of selection
"
" Notes:
" o Restoration of selection is usually accurate, but not in some rare
" instances where it is shifted one char.
"
" ChangeLog:
"
" 2008-01-22 -- 2.4
" o Lowercase articles for Title Case
" o Added optional additional lowercasing for Title Case
"
" 2003-12-06 -- 2.3
" o Fixed errant function name calls. ;)
"
" 2003-12-06 -- 2.2
" o Added mappings back in script for use outside of Cream.
" o Cleaned out obsolete algorithm and embedded new single line from
" formerly called function.
" o Changed function name for title case to be consistent with
" remainder.
"
" 2003-05-07 -- 2.1
" o Changed algorithm in Title Case to simple substitution. (Benji
" Fisher)
"
" 2002-11-13 -- 2.0
" o Functionalized all mappings.
" o Destroyed standalone state with references to Cream libraries.
" o Made functions mode sensitive. From insertmode, each function
" affects the current word.
"
" 2002-04-15 -- 1.3
" o Fixed positioning "anomalies" for title case. (Hopefully for good!)
"
" 2002-03-26 -- 1.2
" o Work around broken Vim paste back behavior at column 1
"
" 2002-03-25 -- 1.1
" o Modified title case function to lower case all text before
" capitalizing initial characters.
"
" 2002-03-10
" o Initial Release
"
" mappings (if not used with Cream)
if !exists("$CREAM")
" Title Case
imap <silent> <F5> <C-b>:call Cream_case_title("i")<CR>
vmap <silent> <F5> :<C-u>call Cream_case_title("v")<CR>
" UPPERCASE
imap <silent> <S-F5> <C-b>:call Cream_case_upper("i")<CR>
vmap <silent> <S-F5> :<C-u>call Cream_case_upper("v")<CR>
" lowercase
imap <silent> <M-F5> <C-b>:call Cream_case_lower("i")<CR>
vmap <silent> <M-F5> :<C-u>call Cream_case_lower("v")<CR>
" rEVERSE CASE
imap <silent> <C-F5> <C-b>:call Cream_case_reverse("i")<CR>
vmap <silent> <C-F5> :<C-u>call Cream_case_reverse("v")<CR>
endif
function! Cream_case_title(mode)
" Title Case -- uppercase characters following whitespace
if a:mode == "v"
normal gv
" Hack: fix Vim's gv proclivity to add a line when at line end
if virtcol(".") == 1
normal '>
" line select
normal gV
" up one line
normal k
" back to char select
normal gV
"""" back up one char
"""normal h
endif
else
let mypos = Cream_pos()
" select current word
normal v
normal aw
endif
" yank
normal "xy
" lower case entire string
let @x = tolower(@x)
" capitalize first in series of word chars
let @x = substitute(@x, '\w\+', '\u&', 'g')
" lowercase a few words we always want lower
let @x = substitute(@x, '\<A\>', 'a', 'g')
let @x = substitute(@x, '\<An\>', 'an', 'g')
let @x = substitute(@x, '\<And\>', 'and', 'g')
let @x = substitute(@x, '\<In\>', 'in', 'g')
let @x = substitute(@x, '\<The\>', 'the', 'g')
" fix first word again
let @x = substitute(@x, '^.', '\u&', 'g')
" fix last word again
let str = matchstr(@x, '[[:alnum:]]\+[^[:alnum:]]*$')
let @x = substitute(@x, str . '$', '\u&', 'g')
"" optional lowercase...
"let n = confirm(
" \ "Lowercase additional conjunctions, adpositions, articles, and forms of \"to be\"?\n" .
" \ "\n", "&Ok\n&Cancel", 2, "Info")
"if n == 1
" " lowercase conjunctions
" let @x = substitute(@x, '\<After\>', 'after', 'g')
" let @x = substitute(@x, '\<Although\>', 'although', 'g')
" let @x = substitute(@x, '\<And\>', 'and', 'g')
" let @x = substitute(@x, '\<Because\>', 'because', 'g')
" let @x = substitute(@x, '\<Both\>', 'both', 'g')
" let @x = substitute(@x, '\<But\>', 'but', 'g')
" let @x = substitute(@x, '\<Either\>', 'either', 'g')
" let @x = substitute(@x, '\<For\>', 'for', 'g')
" let @x = substitute(@x, '\<If\>', 'if', 'g')
" let @x = substitute(@x, '\<Neither\>', 'neither', 'g')
" let @x = substitute(@x, '\<Nor\>', 'nor', 'g')
" let @x = substitute(@x, '\<Or\>', 'or', 'g')
" let @x = substitute(@x, '\<So\>', 'so', 'g')
" let @x = substitute(@x, '\<Unless\>', 'unless', 'g')
" let @x = substitute(@x, '\<When\>', 'when', 'g')
" let @x = substitute(@x, '\<While\>', 'while', 'g')
" let @x = substitute(@x, '\<Yet\>', 'yet', 'g')
" " lowercase adpositions
" let @x = substitute(@x, '\<As\>', 'as', 'g')
" let @x = substitute(@x, '\<At\>', 'at', 'g')
" let @x = substitute(@x, '\<By\>', 'by', 'g')
" let @x = substitute(@x, '\<For\>', 'for', 'g')
" let @x = substitute(@x, '\<From\>', 'from', 'g')
" let @x = substitute(@x, '\<In\>', 'in', 'g')
" let @x = substitute(@x, '\<Of\>', 'of', 'g')
" let @x = substitute(@x, '\<On\>', 'on', 'g')
" let @x = substitute(@x, '\<Over\>', 'over', 'g')
" let @x = substitute(@x, '\<To\>', 'to', 'g')
" let @x = substitute(@x, '\<With\>', 'with', 'g')
" " lowercase articles
" let @x = substitute(@x, '\<A\>', 'a', 'g')
" let @x = substitute(@x, '\<An\>', 'an', 'g')
" let @x = substitute(@x, '\<The\>', 'the', 'g')
" " lowercase forms of to be
" let @x = substitute(@x, '\<Be\>', 'be', 'g')
" let @x = substitute(@x, '\<To\> \<Be\>', 'to be', 'g')
" let @x = substitute(@x, '\<To\> \<Do\>', 'to do', 'g')
" " lowercase prepositions
" " lowercase conjunctions
"endif
" reselect
normal gv
" paste over selection (replacing it)
normal "xP
" return state
if a:mode == "v"
normal gv
else
execute mypos
endif
endfunction
function! Cream_case_lower(mode)
" accepts "v" or "i" as mode
if a:mode == "v"
normal gv
else
let mypos = Cream_pos()
" select current word
normal v
normal aw
endif
" lower case
normal u
" return state
if a:mode == "v"
normal gv
else
execute mypos
endif
endfunction
function! Cream_case_upper(mode)
" accepts "v" or "i" as mode
if a:mode == "v"
normal gv
else
let mypos = Cream_pos()
" select current word
normal v
normal aw
endif
" UPPER CASE
normal U
" return state
if a:mode == "v"
normal gv
else
execute mypos
endif
endfunction
function! Cream_case_reverse(mode)
" accepts "v" or "i" as mode
if a:mode == "v"
normal gv
else
let mypos = Cream_pos()
" select current word
normal v
normal aw
endif
" rEVERSE cASE
normal ~
" return state
if a:mode == "v"
normal gv
else
execute mypos
endif
endfunction
|