sponsor Vim development Vim logo Vim Book Ad

cream-iso3166-1 : Find ISO 3166-1 country codes and names

 script karma  Rating 7/3, Downloaded by 441    Comments, bugs, improvements  Vim wiki

created by
Steve Hall
 
script type
utility
 
description

Find the matching ISO3166-1 (http://en.wikipedia.org/wiki/ISO_3166-1) country code or name when passed the other.


Usage

  Cream_iso3166_1(word, ...)

o Test {word} for match of iso3166_1-compliant country name, 3- or 2-letter abbreviation, or 3-digit numerical code:
  * Returns name if {word} matches either abbreviation.
  * Returns 2-letter if {word} matches name or number.
  * Returns 0 if no match is made.
o Use {optional} argument to force a given return:
  * Returns 3-letter if {optional} is "3" and {word} matches.
  * Returns 2-letter if {optional} is "2" and {word} matches.
  * Returns name if {optional} is "name" and {word} matches.
  * Returns number if {optional} is "number" and {word} matches.
  * Returns 0 if no match is made.
o Matching is case-insensitive. But return values are capitalized according to the standard. (Name is title case, abbreviations are UPPER CASE.)


Examples

  :echo Cream_iso3166_1("AND")               returns "Andorra"
  :echo Cream_iso3166_1("AD")                  returns "Andorra"
  :echo Cream_iso3166_1("Andorra")          returns "AD"
  :echo Cream_iso3166_1("020")                 returns "AD"

  Return format forced:

  :echo Cream_iso3166_1("AND", "3")        returns "AND"
  :echo Cream_iso3166_1("AD", "3")           returns "AND"
  :echo Cream_iso3166_1("Andorra", "3")   returns "AND"
  :echo Cream_iso3166_1("020", "3")          returns "AND"

  :echo Cream_iso3166_1("020", "2")          returns "AD"
  :echo Cream_iso3166_1("020", "name")   returns "Andorra"
  :echo Cream_iso3166_1("AD", "number") returns "020"

  Name or abbreviation unmatched:

  :echo Cream_iso3166_1("not-a-name")     returns 0
  :echo Cream_iso3166_1("not")                   returns 0

 
install details

Simply copy this file and paste it into your vimrc. Or you can drop the entire file into your plugins directory.

 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
cream-iso3166-1.vim 1.0 2004-07-17 6.0 Steve Hall Initial upload
ip used for rating: 54.163.70.249

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo