Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (38 sloc) 1.82 KB
<h3 id="changing-case-of-text">Changing the Case of Text</h3>
<p>You want to change the case of a character or block of text. For example,
you may want to change <i>bob</i> to <i>Bob</i>.</p>
<dd>Toggles the case of the current character in Normal mode, or the
selection in <a href="#visually-selecting-text"><i>Visual</i></a> mode.</dd>
<dd>Lowercases highlighted text. (Note: This only works in <i>Visual</i>
mode; otherwise <kbd>u</kbd> will undo your last change).</dd>
<dd>Uppercases highlighted text. (Note: This only works in <i>Visual</i>
mode; otherwise <kbd>U</kbd> will undo the changes made on the current
<p>As normal, these commands accept <a
href="#selecting-text-with-motions"><i>motions</i></a>. For example:</p>
<dd>Uppercase current line.</dd>
<dd>Lowercases current word.</dd>
<p>To convert a string to <i>title case</i>, i.e. initial capitals, you can
use the following <a href="#creating-regular-expressions">regular
expression</a>: <code>s/\&lt;\(\w\)\(\w*\)\&gt;/\u\1\L\2/g</code>. <a
href="#visually-selecting-text">Select the text</a> you want to convert, hit
<kbd>:</kbd>, then enter the regular expression. If you use this regularly,
consider <a href="#creating-keyboard-shortcuts-with-key-mappings">remapping a
key</a> to execute this command. For example:</p>
<pre><code>nnoremap &lt;F7&gt; :s/\&lt;\(\w\)\(\w*\)\&gt;/\u\1\L\2/g&lt;CR&gt;
vnoremap &lt;F7&gt; :s/\%V\(\w\)\(\w*\)\%V/\u\1\L\2/g&lt;CR&gt;</code></pre>
<p>Alternatively, you can install the <a
<a href="#extending-vim-with-scripts-plugins">plugin</a>.</p>
Something went wrong with that request. Please try again.