Difference between revisions of "Vi"
From Christoph's Personal Wiki
(+links/Cat) |
|||
Line 2: | Line 2: | ||
'''vi''' is a screen-oriented text editor computer program run from the [[:Category:Linux Command Line Tools|command line]]. | '''vi''' is a screen-oriented text editor computer program run from the [[:Category:Linux Command Line Tools|command line]]. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Commands == | == Commands == | ||
Line 107: | Line 99: | ||
</td></tr> | </td></tr> | ||
</table> | </table> | ||
+ | |||
+ | == Switching cases == | ||
+ | |||
+ | In the replacement part of a substitution command, i.e. between the second "/" and third "/", | ||
+ | |||
+ | \u means make the following character upper case | ||
+ | \l means make the following character lower case | ||
+ | \U means make the rest of the replacement upper case | ||
+ | \L means make the rest of the replacement lower case | ||
+ | |||
+ | * Make the first letter of every word from line 18 to 43 uppercase: | ||
+ | |||
+ | :18,43s/\<./\u&/g | ||
+ | |||
+ | * Change "uPPeR" and "LoweR" in any mixture of cases to lowercase: | ||
+ | |||
+ | :s/[UuLl][PpOo][PpWw][Ee][Rr]/\L&/ | ||
+ | |||
+ | * Make the whole file uppercase: | ||
+ | |||
+ | :%s/.*/\U&/ | ||
+ | |||
+ | * Make the region from line m to line n all uppercase: | ||
+ | |||
+ | :'m,'ns/.*/\U&/ | ||
+ | |||
+ | * Make a paragraph all lowercase: | ||
+ | |||
+ | :?^$?,/^$/s/.*/\L&/ | ||
+ | |||
+ | * Make the first letter of every word in a paragraph uppercase: | ||
+ | |||
+ | :?^$?,/^$/s/\([^ ][^ ]*\)/\u&/g | ||
+ | |||
+ | * Make the second word of each line uppercase: | ||
+ | |||
+ | :1,$s/^\([^ ]*\) \([^ ]*\) \(.*\)/\1 \U\2\e \3/ | ||
+ | |||
+ | == Configuring vi/vim == | ||
+ | |||
+ | It is possible to extensively configure <code>vi</code> (or <code>vim</code>) to suit your personal needs. | ||
+ | |||
+ | For an example, if you would like syntax-highlighting to be used by default for most of your code files, edit your <code>.vimrc</code> file (located in your "home" directory. If one does not exist, create it) and add the following line: | ||
+ | |||
+ | syn on | ||
[[Category:Linux Command Line Tools]] | [[Category:Linux Command Line Tools]] | ||
[[Category:Technical and Specialized Skills]] | [[Category:Technical and Specialized Skills]] |
Revision as of 06:44, 26 August 2006
- The correct title of this article is vi. The initial letter is capitalized due to technical restrictions.
vi is a screen-oriented text editor computer program run from the command line.
Commands
Below is a very short list of the most useful commands:
|
|
Switching cases
In the replacement part of a substitution command, i.e. between the second "/" and third "/",
\u means make the following character upper case \l means make the following character lower case \U means make the rest of the replacement upper case \L means make the rest of the replacement lower case
- Make the first letter of every word from line 18 to 43 uppercase:
:18,43s/\<./\u&/g
- Change "uPPeR" and "LoweR" in any mixture of cases to lowercase:
:s/[UuLl][PpOo][PpWw][Ee][Rr]/\L&/
- Make the whole file uppercase:
:%s/.*/\U&/
- Make the region from line m to line n all uppercase:
:'m,'ns/.*/\U&/
- Make a paragraph all lowercase:
:?^$?,/^$/s/.*/\L&/
- Make the first letter of every word in a paragraph uppercase:
:?^$?,/^$/s/\([^ ][^ ]*\)/\u&/g
- Make the second word of each line uppercase:
:1,$s/^\([^ ]*\) \([^ ]*\) \(.*\)/\1 \U\2\e \3/
Configuring vi/vim
It is possible to extensively configure vi
(or vim
) to suit your personal needs.
For an example, if you would like syntax-highlighting to be used by default for most of your code files, edit your .vimrc
file (located in your "home" directory. If one does not exist, create it) and add the following line:
syn on