abstract
| - Or, you can keep a single file, and use Vim to organize it, in the same way that Vim organizes its Help. Here is an extract from my own Memo: *memo.txt* My Memo - extending my poor memory |guide| ---------------------------------------------------------------- *subjects* *toc* |cmd| command tips |def| definitions |dev| developments |ed| editors |friends| friends |lang| languages |misc| others |private| personal info |sys| system ---------------------------------------------------------------- Commands *cmd* *General <a href="http://www.cslab.vt.edu/manuals">http://www.cslab.vt.edu/manuals</a> ... |doskey| DOS key utility : expand history |man| Unix manual man foo nroff -man foo.1 | less nroff -man foo.1 | a2ps -m |unix| <a href="http://gd.tuwien.ac.at/linuxcommand.org/">http://gd.tuwien.ac.at/linuxcommand.org/</a> |winhelp| ... ---------------------------------------------------------------- Development *develop* *dev* ... ---------------------------------------------------------------- vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl: Some explanations: The last line instructs Vim with a number of editing settings. The most important one here is "ft=help", which says file-type is "help". So Vim will highlight things for us. You can use *foo* to indicate an anchor to the "help" system of Vim. If you press Ctrl+] on a word "foo", the cursor will jump to the first *foo*. You can also see |foo| as a way to highlight it as implicit keywords. This is not magic. The mechanism behind it is the tag system. Vim needs to have the following tag file to go to where you want it to go: %userprofile% memo.txt /*%userprofile%* .htaccess meo.txt /*.htaccess* access memo.txt /*access* access.conf memo.txt /*access.conf* addressbook memo.txt /*addressbook* anchor_keyword memo.txt /*anchor_keyword* apache memo.txt /*apache* as index.txt /*as* at index.txt /*at* awk index.txt /*awk* Each line defines a tag, the first element is the keyword, the second is the file where the tag belongs (yes, you can use multiple files as long as you know what they are), and the last element is the command which Vim has to perform at the keyword. How to write these tags? You can find this utility to do it: cc doctags.c -o doctags doctags memo.txt | sort -f | awk -f cases.awk >tags uniq -d -2 tags /* doctags.c (see Vim source!) */ /* vim:set ts=4 sw=4: * this program makes a tags file for vim_ref.txt * * Usage: doctags vim_ref.txt vim_win.txt ... >tags * * A tag in this context is an identifier between stars, e.g. *c_files* */ #include #include #include #include #define LINELEN 200 int main(argc, argv) int argc; char **argv; { char line[LINELEN]; char *p1, *p2; char *p; FILE *fd; if (argc <= 1) { fprintf(stderr, "Usage: doctags docfile ... >tags
"); exit(1); } printf("help-tags tags 1
"); while (--argc > 0) { ++argv; fd = fopen(argv[0], "r"); if (fd == NULL) { fprintf(stderr, "Unable to open %s for reading
", argv[0]); continue; } while (fgets(line, LINELEN, fd) != NULL) { p1 = strchr(line, '*'); /* find first '*' */ while (p1 != NULL) { p2 = strchr(p1 + 1, '*'); /* find second '*' */ if (p2 != NULL && p2 > p1 + 1) /* skip "*" and "**" */ { for (p = p1 + 1; p < p2; ++p) if (*p == ' ' || *p == ' ' || *p == '|') break; /* * Only accept a *tag* when it consists of valid * characters and is followed by a white character or * end-of-line. */ if (p == p2 && (p1 == line || p1[-1] != '-') && (strchr("
", p[1]) != NULL || p[1] == '\0')) { *p2 = '\0'; ++p1; printf("%s %s /*", p1, argv[0]); while (*p1) { /* insert backslash before '\' and '/' */ if (*p1 == '\' || *p1 == '/') putchar('\'); putchar(*p1); ++p1; } printf("*
"); p2 = strchr(p2 + 1, '*'); /* find next '*' */ } } p1 = p2; } } fclose(fd); } return 0; } /* cases.awk */ { print tolower($1) " " $2 " " tolower($3); }
|