Vim

From 43FoldersWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 22:22, 19 April 2005 (edit)
ThePolack (Talk | contribs)
m
← Previous diff
Revision as of 22:24, 19 April 2005 (edit) (undo)
JamesRifkin (Talk | contribs)

Next diff →
Line 1: Line 1:
-Vim, or "vi improved" is a [[:Category:Text Editors|text editor]] by Bram Moolenaar. It is an enhanced version of "the unix text editor," vi, which is in turn based on ed and ex. +{{Infobox_Software|
 + software_name=Vim|
 + OS=many|
 + license_type=Charityware|
 + cost=$0|
 + dl_size=??|
 + site_url=http://www.vim.org/]
 +}}
-==Links==+==Description==
-* [http://www.vim.org/ Vim Online]+Vim, or "vi improved" is a [[:Category:Text Editors|text editor]] by Bram Moolenaar. It is an enhanced version of "the unix text editor," vi, which is in turn based on ed and ex.
-* [http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl Vim FAQs]+
-* [http://www.macvim.org/ Mac Vim] features binaries for [http://macvim.org/OSX/ OS X] and Classic+
-* [http://www.43folders.com/2005/03/remainders_vim_.html 43F comments thread full of good Vim tips]+
 +==Testimonials==
-== Tips for mastering vim ==+The Linux Journal magazine in its annual Readers' Choice Award selected vim as favorite text editor four years in a row!
-Vim is a +==Hacks==
-[http://vim.sourceforge.net/download.php free cross-platform] +
-(*nix, Mac, Windows) text editor with amazing depth, adaptable to the way you work. +
-In a nutshell, one can swiftly edit CONTENT (as opposed to the +
-CONTAINER, cf. M$ Word). The Linux Journal magazine in its annual Readers' Choice Award selected vim as favorite text editor -- four years in a row! +
-Some of the best TIPS are found at +=== Join the Mailing List ===
-[http://vim.sourceforge.net/tips/tip_search_results.php?order_by=rating sourceforge.net]. + 
-The vim community is very friendly and helpful. Their archived forum is publicly +# subscribe to the list by sending a message to vim-subscribe@vim.org
-accessible via +# read the [http://groups.yahoo.com/group/vim/messages archives]
-[http://groups.yahoo.com/group/vim/messages Yahoo group] for Q&A and RSS access. +
-(Before posting a message you must+
-subscribe to the list by sending a message to+
-vim-subscribe@vim.org .) Bram Moolenaar, the chief programmer par excellence, often +
-responds to queries. --[[User:Gochess|gochess]] 13:07, 19 Apr 2005 (EDT)+
=== Editing files that use non-Unix end-of-line characters === === Editing files that use non-Unix end-of-line characters ===
Line 48: Line 44:
:help substitute :help substitute
:help pattern :help pattern
 +
 +==See Also==
 +* [http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl Vim FAQs]
 +* [http://vim.sourceforge.net/tips/tip_search_results.php?order_by=rating Vim Tips
 +* [http://www.macvim.org/ Mac Vim] features binaries for OS X and Classic
 +* [http://www.43folders.com/2005/03/remainders_vim_.html 43F comments thread full of good Vim tips]
[[Category: Cross-Platform Software]] [[Category:Text Editors]] [[Category: Open Source]] [[Category: Cross-Platform Software]] [[Category:Text Editors]] [[Category: Open Source]]

Revision as of 22:24, 19 April 2005

Vim
Platform: many
License: Charityware
Cost: $0
Download Size:  ??
Site: http://www.vim.org/]

Contents

Description

Vim, or "vi improved" is a text editor by Bram Moolenaar. It is an enhanced version of "the unix text editor," vi, which is in turn based on ed and ex.

Testimonials

The Linux Journal magazine in its annual Readers' Choice Award selected vim as favorite text editor four years in a row!

Hacks

Join the Mailing List

  1. subscribe to the list by sending a message to vim-subscribe@vim.org
  2. read the archives

Editing files that use non-Unix end-of-line characters

Sometimes, you open a text file and the line formatting is all wrong and there are loads of annoying '^M' characters spread all throughout it. If you're using vim on a Mac, you are likely to encounter this problem a lot because it is caused when a Mac-formatted text file is opened in vim because vim prefers text files that are Unix-formatted. You could also run into similar problems with Windows-formatted text files. Luckily, this is an easy thing to deal with in vim.

Solution #1: Type :set fileformat unix and hit enter while in edit (not insert) mode. This should reformat the file for you and solve the problem.

Solution #2: Sometimes solution #1 doesn't work. So it is not recommended that you use it. Instead, use global search and replace to fix the files. While in edit mode, type :%s/\r/\r/g and hit enter. This will replace all Mac-formatted carriage returns with unix-formatted newlines. This seems counter-intuitive since you're telling the editor to replace carriage returns with carriage returns, but it works because of how vim interprets a carriage return command. Using the same fix to change a Windows file to a Unix file would require a different pattern, like this: :%s/^M//g (be sure to use ctrl-M when typing the ^M in the pattern, don't type a '^' character followed by a 'M' character).

If typing that pattern in every time you need it seems a bit much, just map it to a key command. For example, put the following lines in your .vimrc file in your home directory:

nnoremap M :%s/\r/\r/g <CR>
vnoremap M :%s/\r/\r/g <CR>
nnoremap W :%s/^M//g <CR> # Remember to type the ^M with ctrl-M and not with '^' followed by 'M'
vnoremap W :%s/^M//g <CR> 

Now the command to convert Mac text files into Unix text files is mapped to the uppercase 'M' in edit mode, so you can just type that command the instant you load the file and see that it's broken. Similarly, the command to convert Windows text files to Unix files is mapped to the uppercase 'W'. Additionally, if you use the commands while you have selected text in the file, the changes will only occur to that portion of the file that you have selected.

If you want to better understand these commands, use vim's built-in help with these commands:

:help mapping
:help substitute
:help pattern

See Also

Personal tools