Mercurial > vim
comparison runtime/doc/usr_22.txt @ 1618:46bbe11644e0
updated for version 7.2a
author | vimboss |
---|---|
date | Tue, 24 Jun 2008 20:19:36 +0000 |
parents | fa824a910372 |
children | 0b796e045c42 |
comparison
equal
deleted
inserted
replaced
1617:5f0c7aae4da2 | 1618:46bbe11644e0 |
---|---|
1 *usr_22.txt* For Vim version 7.1. Last change: 2006 Apr 24 | 1 *usr_22.txt* For Vim version 7.2a. Last change: 2007 Aug 14 |
2 | 2 |
3 VIM USER MANUAL - by Bram Moolenaar | 3 VIM USER MANUAL - by Bram Moolenaar |
4 | 4 |
5 Finding the file to edit | 5 Finding the file to edit |
6 | 6 |
8 Files can be found everywhere. So how do you find them? Vim offers various | 8 Files can be found everywhere. So how do you find them? Vim offers various |
9 ways to browse the directory tree. There are commands to jump to a file that | 9 ways to browse the directory tree. There are commands to jump to a file that |
10 is mentioned in another. And Vim remembers which files have been edited | 10 is mentioned in another. And Vim remembers which files have been edited |
11 before. | 11 before. |
12 | 12 |
13 |22.1| The file explorer | 13 |22.1| The file browser |
14 |22.2| The current directory | 14 |22.2| The current directory |
15 |22.3| Finding a file | 15 |22.3| Finding a file |
16 |22.4| The buffer list | 16 |22.4| The buffer list |
17 | 17 |
18 Next chapter: |usr_23.txt| Editing other files | 18 Next chapter: |usr_23.txt| Editing other files |
19 Previous chapter: |usr_21.txt| Go away and come back | 19 Previous chapter: |usr_21.txt| Go away and come back |
20 Table of contents: |usr_toc.txt| | 20 Table of contents: |usr_toc.txt| |
21 | 21 |
22 ============================================================================== | 22 ============================================================================== |
23 *22.1* The file explorer | 23 *22.1* The file browser |
24 | 24 |
25 Vim has a plugin that makes it possible to edit a directory. Try this: > | 25 Vim has a plugin that makes it possible to edit a directory. Try this: > |
26 | 26 |
27 :edit . | 27 :edit . |
28 | 28 |
29 Through the magic of autocommands and Vim scripts, the window will be filled | 29 Through the magic of autocommands and Vim scripts, the window will be filled |
30 with the contents of the directory. It looks like this: | 30 with the contents of the directory. It looks like this: |
31 | 31 |
32 " Press ? for keyboard shortcuts ~ | 32 " ============================================================================ ~ |
33 " Sorted by name (.bak,~,.o,.h,.info,.swp,.obj,.orig,.rej at end of list) ~ | 33 " Netrw Directory Listing (netrw v109) ~ |
34 "= /home/mool/vim/vim6/runtime/doc/ ~ | 34 " Sorted by name ~ |
35 ../ ~ | 35 " Sort sequence: [\/]$,\.h$,\.c$,\.cpp$,*,\.info$,\.swp$,\.o$\.obj$,\.bak$ ~ |
36 check/ ~ | 36 " Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec ~ |
37 Makefile ~ | 37 " ============================================================================ ~ |
38 autocmd.txt ~ | 38 ../ ~ |
39 change.txt ~ | 39 ./ ~ |
40 eval.txt~ ~ | 40 check/ ~ |
41 filetype.txt~ ~ | 41 Makefile ~ |
42 help.txt.info ~ | 42 autocmd.txt ~ |
43 change.txt ~ | |
44 eval.txt~ ~ | |
45 filetype.txt~ ~ | |
46 help.txt.info ~ | |
43 | 47 |
44 You can see these items: | 48 You can see these items: |
45 1. A comment about using ? to get help for the functionality of the file | 49 |
46 explorer. | 50 1. The name of the browsing tool and its version number |
47 2. The second line mentions how the items in the directory are listed. They | 51 2. The name of the browsing directory |
48 can be sorted in several ways. | 52 3. The method of sorting (may be by name, time, or size) |
49 3. The third line is the name of the current directory. | 53 4. How names are to be sorted (directories first, then *.h files, |
50 4. The "../" directory item. This is the parent directory. | 54 *.c files, etc) |
51 5. The directory names. | 55 5. How to get help (use the <F1> key), and an abbreviated listing |
52 6. The ordinary file names. As mentioned in the second line, some are not | 56 of available commands |
53 here but "at the end of the list". | 57 6. A listing of files, including "../", which allows one to to list |
54 7. The less ordinary file names. You are expected to use these less often, | 58 the parent directory. |
55 therefore they have been moved to the end. | |
56 | 59 |
57 If you have syntax highlighting enabled, the different parts are highlighted | 60 If you have syntax highlighting enabled, the different parts are highlighted |
58 to make it easier to spot them. | 61 so as to make it easier to spot them. |
59 | 62 |
60 You can use Normal mode Vim commands to move around in the text. For example, | 63 You can use Normal mode Vim commands to move around in the text. For example, |
61 move to a file and press <Enter>. Now you are editing that file. To go back | 64 move the cursor atop a file and press <Enter>; you will then be editing that |
62 to the explorer use ":edit ." again. CTRL-O also works. | 65 file. To go back to the browser use ":edit ." again, or use ":Explore". |
63 Try using <Enter> while the cursor is on a directory name. The result is | 66 CTRL-O also works. |
64 that the explorer moves into that directory and displays the items found | 67 |
68 Try using <Enter> while the cursor is atop a directory name. The result is | |
69 that the file browser moves into that directory and displays the items found | |
65 there. Pressing <Enter> on the first directory "../" moves you one level | 70 there. Pressing <Enter> on the first directory "../" moves you one level |
66 higher. Pressing "-" does the same thing, without the need to move to the | 71 higher. Pressing "-" does the same thing, without the need to move to the |
67 "../" item first. | 72 "../" item first. |
68 | 73 |
69 You can press ? to get short help on the things you can do in the explorer. | 74 You can press <F1> to get help on the things you can do in the netrw file |
70 This is what you get: | 75 browser. This is what you get: > |
71 | 76 |
72 " <enter> : open file or directory ~ | 77 9. Directory Browsing netrw-browse netrw-dir netrw-list netrw-help |
73 " o : open new window for file/directory ~ | 78 |
74 " O : open file in previously visited window ~ | 79 MAPS netrw-maps |
75 " p : preview the file ~ | 80 <F1>.............Help.......................................|netrw-help| |
76 " i : toggle size/date listing ~ | 81 <cr>.............Browsing...................................|netrw-cr| |
77 " s : select sort field r : reverse sort ~ | 82 <del>............Deleting Files or Directories..............|netrw-delete| |
78 " - : go up one level c : cd to this dir ~ | 83 -................Going Up...................................|netrw--| |
79 " R : rename file D : delete file ~ | 84 a................Hiding Files or Directories................|netrw-a| |
80 " :help file-explorer for detailed help ~ | 85 mb...............Bookmarking a Directory....................|netrw-mb| |
81 | 86 gb...............Changing to a Bookmarked Directory.........|netrw-gb| |
82 The first few commands are for selecting a file to display. Depending on what | 87 c................Make Browsing Directory The Current Dir....|netrw-c| |
83 command you use, the file appears somewhere: | 88 d................Make A New Directory.......................|netrw-d| |
84 | 89 D................Deleting Files or Directories..............|netrw-D| |
85 <Enter> Uses the current window. | 90 <c-h>............Edit File/Directory Hiding List............|netrw-ctrl-h| |
86 o Opens a new window. | 91 i................Change Listing Style.......................|netrw-i| |
87 O Uses the previously visited window. | 92 <c-l>............Refreshing the Listing.....................|netrw-ctrl-l| |
88 p Uses the preview window, and moves the cursor back | 93 o................Browsing with a Horizontal Split...........|netrw-o| |
89 into the explorer window. |preview-window| | 94 p................Use Preview Window.........................|netrw-p| |
90 | 95 P................Edit in Previous Window....................|netrw-p| |
91 The following commands are used to display other information: | 96 q................Listing Bookmarks and History..............|netrw-q| |
92 | 97 r................Reversing Sorting Order....................|netrw-r| |
93 i Display the size and date for the file. Using i again | 98 < (etc) |
94 will hide the information. | 99 |
95 s Use the field the cursor is in to sort on. First | 100 The <F1> key thus brings you to a netrw directory browsing contents help page. |
96 display the size and date with i. Then Move the | 101 Its a regular help page; use the usual |CTRL-]| to jump to tagged help items |
97 cursor to the size of any file and press s. The files | 102 and |CTRL-O| to jump back. |
98 will now be sorted on size. Press s while the cursor | 103 |
99 is on a date and the items will be sorted on date. | 104 To select files for display and editing: (with the cursor is atop a filename) |
100 r reverse the sorting order (either size or date) | 105 |
101 | 106 <enter> Open the file in the current window. |netrw-cr| |
102 There are a few extra commands: | 107 o Horizontally split window and display file |netrw-o| |
103 | 108 v Vertically split window and display file |netrw-v| |
104 c Change the current directory to the displayed | 109 p Use the |preview-window| |netrw-p| |
105 directory. You can then type an ":edit" command for | 110 P Edit in the previous window |netrw-P| |
106 one of the files without prepending the path. | 111 t Open file in a new tab |netrw-t| |
107 R Rename the file under the cursor. You will be | 112 |
108 prompted for the new name. | 113 The following normal-mode commands may be used to control the browser display: |
109 D Delete the file under the cursor. You will get a | 114 |
110 prompt to confirm this. | 115 i Controls listing style (thin, long, wide, and tree). |
116 The long listing includes size and date information. | |
117 s Repeatedly pressing s will change the way the files | |
118 are sorted; one may sort on name, modification time, | |
119 or size. | |
120 r Reverse the sorting order. | |
121 | |
122 As a sampling of extra normal-mode commands: | |
123 | |
124 c Change Vim's notion of the current directory to be | |
125 the same as the browser directory. (see | |
126 |g:netrw_keepdir| to control this, too) | |
127 R Rename the file or directory under the cursor; a | |
128 prompt will be issued for the new name. | |
129 D Delete the file or directory under the cursor; a | |
130 confirmation request will be issued. | |
131 mb gb Make bookmark/goto bookmark | |
132 | |
133 | |
134 One may also use command mode; again, just a sampling: | |
135 | |
136 :Explore [directory] Browse specified/current directory | |
137 :NetrwSettings A comprehensive list of your current netrw | |
138 settings with help linkage. | |
139 | |
140 The netrw browser is not limited to just your local machine; one may use | |
141 urls such as: (that trailing / is important) | |
142 | |
143 :Explore ftp://somehost/path/to/dir/ | |
144 :e scp://somehost/path/to/dir/ | |
145 | |
146 See |netrw-browse| for more. | |
111 | 147 |
112 ============================================================================== | 148 ============================================================================== |
113 *22.2* The current directory | 149 *22.2* The current directory |
114 | 150 |
115 Just like the shell, Vim has the concept of a current directory. Suppose you | 151 Just like the shell, Vim has the concept of a current directory. Suppose you |
253 :hide edit two.txt | 289 :hide edit two.txt |
254 | 290 |
255 The buffer "one.txt" disappears from the screen, but Vim still knows that you | 291 The buffer "one.txt" disappears from the screen, but Vim still knows that you |
256 are editing this buffer, so it keeps the modified text. This is called a | 292 are editing this buffer, so it keeps the modified text. This is called a |
257 hidden buffer: The buffer contains text, but you can't see it. | 293 hidden buffer: The buffer contains text, but you can't see it. |
258 The ":hide" command argument is another command. It makes that command | 294 The argument of ":hide" is another command. ":hide" makes that command |
259 behave like the 'hidden' option was set. You could also set this option | 295 behave as if the 'hidden' option was set. You could also set this option |
260 yourself. The effect is that when any buffer is abandoned, it becomes hidden. | 296 yourself. The effect is that when any buffer is abandoned, it becomes hidden. |
261 Be careful! When you have hidden buffers with changes, don't exit Vim | 297 Be careful! When you have hidden buffers with changes, don't exit Vim |
262 without making sure you have saved all the buffers. | 298 without making sure you have saved all the buffers. |
263 | 299 |
264 | 300 |