summaryrefslogtreecommitdiff
path: root/mnv/runtime/doc/usr_22.txt
blob: d6efdb14b11c5c7bd82badc7e54580ef452702aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
*usr_22.txt*	For MNV version 10.0.  Last change: 2026 Feb 14


		     MNV USER MANUAL	by Bram Moolenaar


			   Finding the file to edit


Files can be found everywhere.  So how do you find them?  MNV offers various
ways to browse the directory tree.  There are commands to jump to a file that
is mentioned in another.  And MNV remembers which files have been edited
before.

|22.1|	The file browser
|22.2|	The current directory
|22.3|	Finding a file
|22.4|	The buffer list

     Next chapter: |usr_23.txt|  Editing other files
 Previous chapter: |usr_21.txt|  Go away and come back
Table of contents: |usr_toc.txt|

==============================================================================
*22.1*	The file browser

MNV has a plugin that makes it possible to edit a directory.  Try this: >

	:edit .

Through the magic of autocommands and MNV scripts, the window will be filled
with the contents of the directory.  It looks like this (slightly cleaned up
so that it fits within 78 chars): >

  " ==========================================================================
  " Netrw Directory Listing                                       (netrw v184)
  "   /path/to/mnv/runtime/doc
  "   Sorted by      name
  "   Sort sequence: [\/]$,*,\(\.bak\|\~\|\.o\|\.h\|\.info\|\.swp\)[*@]\=$
  "   Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:special
  " ==========================================================================
  ../
  ./
  check/
  Makefile
  autocmd.txt
  change.txt
  eval.txt
  filetype.txt
  help.txt.info

You can see these items:

1. The name of the browsing tool and its version number
2. The name of the browsing directory
3. The method of sorting (may be by name, time, or size)
4. How names are to be sorted (directories first, then by extension, etc.)
5. How to get help (the <F1> key), and an abridged list of available commands
6. A listing of files, including "../" (it will list the parent directory).

If you have syntax highlighting enabled, the different parts are highlighted
so as to make it easier to spot them.

You can use Normal mode MNV commands to move around in the text.  For example,
move the cursor atop a file and press <Enter>; you will then be editing that
file.  To go back to the browser use ":edit ." again, or use ":Explore".
CTRL-O also works.

Try using <Enter> while the cursor is atop a directory name.  The result is
that the file browser moves into that directory and displays the items found
there.  Pressing <Enter> on the first directory "../" moves you one level
higher.  Pressing "-" does the same thing, without the need to move to the
"../" item first.

You can press <F1> to get help on the things you can do in the netrw file
browser.  This is what you get:
>
 QUICK HELP						netrw-quickhelp
                       (Use ctrl-] to select a topic)
	Intro to Browsing...............................netrw-intro-browse
	  Quick Reference: Maps.........................netrw-quickmap
	  Quick Reference: Commands.....................netrw-browse-cmds
<
The <F1> key thus brings you to a netrw directory browsing contents help page.
It's a regular help page; use the usual |CTRL-]| to jump to tagged help items
and |CTRL-O| to jump back.  So, if you CTRL-] on |netrw-quickmap| you will
jump to this:
>
				netrw-quickmap  netrw-quickmaps
 QUICK REFERENCE: MAPS				netrw-browse-maps

	  ---			-----------------			----
	  Map			Quick Explanation			Link
	  ---			-----------------			----
	 <F1>	Causes Netrw to issue help
	 <cr>	Netrw will enter the directory or read the file      netrw-cr
	 <del>	Netrw will attempt to remove the file/directory      netrw-del
<	 (etc.)

To select files for display and editing (with the cursor atop a filename):
>
	   o	Enter the file/directory under the cursor in a new   netrw-o
		browser window.  A horizontal split is used.
	   O	Obtain a file specified by cursor                    netrw-O
	   p	Preview the file                                     netrw-p
	   P	Browse in the previously used window                 netrw-P
	   v	Enter the file/directory under the cursor in a new   netrw-v
		browser window.  A vertical split is used.
<
The following normal-mode commands may be used to control the browser display:
>
	   i	Cycle between thin, long, wide, and tree listings    netrw-i
	   r	Reverse sorting order                                netrw-r
	   s	Select sorting style: by name, time, or file size    netrw-s
<
As a sampling of extra normal-mode commands:
>
	   cd	Make browsing directory the current directory        netrw-cd
	   D	Attempt to remove the file(s)/directory(ies)         netrw-D
	   gb	Go to previous bookmarked directory                  netrw-gb
	   mb	Bookmark current directory                           netrw-mb
	   R	Rename the designated file(s)/directory(ies)         netrw-R
<
One may also use command mode; again, just a sampling:
>
     :Explore[!]  [dir] Explore directory of current file......netrw-explore
     :Hexplore[!] [dir] Horizontal Split & Explore.............netrw-explore
<
The netrw browser is not limited to just your local machine; one may use URLs
such as: >

	:Explore ftp://somehost/path/to/dir/
	:e scp://somehost/path/to/dir/
<
	Note: The trailing "/" is important.

See |netrw-browse| for more.

==============================================================================
*22.2*	The current directory

Just like the shell, MNV has the concept of a current directory.  Suppose you
are in your home directory and want to edit several files in a directory
"VeryLongFileName".  You could do: >

	:edit VeryLongFileName/file1.txt
	:edit VeryLongFileName/file2.txt
	:edit VeryLongFileName/file3.txt

To avoid much of the typing, do this: >

	:cd VeryLongFileName
	:edit file1.txt
	:edit file2.txt
	:edit file3.txt

The ":cd" command changes the current directory.  You can see what the current
directory is with the ":pwd" command: >

	:pwd
	/home/Bram/VeryLongFileName

MNV remembers the last directory that you used.  Use "cd -" to go back to it.
Example: >

	:pwd
	/home/Bram/VeryLongFileName
	:cd /etc
	:pwd
	/etc
	:cd -
	:pwd
	/home/Bram/VeryLongFileName
	:cd -
	:pwd
	/etc


WINDOW LOCAL DIRECTORY

When you split a window, both windows use the same current directory.  When
you want to edit a number of files somewhere else in the new window, you can
make it use a different directory, without changing the current directory in
the other window.  This is called a local directory. >

	:pwd
	/home/Bram/VeryLongFileName
	:split
	:lcd /etc
	:pwd
	/etc
	CTRL-W w
	:pwd
	/home/Bram/VeryLongFileName

So long as no `:lcd` command has been used, all windows share the same current
directory.  Doing a `:cd` command in one window will also change the current
directory of the other window.
   For a window where `:lcd` has been used a different current directory is
remembered.  Using `:cd` or `:lcd` in other windows will not change it.
   When using a `:cd` command in a window that uses a different current
directory, it will go back to using the shared directory.


TAB LOCAL DIRECTORY

When you open a new tab page, it uses the directory of the window in the
previous tab page from which the new tab page was opened.  You can change the
directory of the current tab page using the `:tcd` command.  All the windows
in a tab page share this directory except for windows with a window-local
directory.  Any new windows opened in this tab page will use this directory as
the current working directory.  Using a `:cd` command in a tab page will not
change the working directory of tab pages which have a tab local directory.
When the global working directory is changed using the `:cd` command in a tab
page, it will also change the current tab page working directory.


==============================================================================
*22.3*	Finding a file

You are editing a C program that contains this line:

	#include "inits.h" ~

You want to see what is in that "inits.h" file.  Move the cursor on the name
of the file and type: >

	gf

MNV will find the file and edit it.
   What if the file is not in the current directory?  MNV will use the 'path'
option to find the file.  This option is a list of directory names where to
look for your file.
   Suppose you have your include files located in "c:/prog/include".  This
command will add it to the 'path' option: >

	:set path+=c:/prog/include

This directory is an absolute path.  No matter where you are, it will be the
same place.  What if you have located files in a subdirectory, below where the
file is?  Then you can specify a relative path name.  This starts with a dot:
>
	:set path+=./proto

This tells MNV to look in the directory "proto", below the directory where the
file in which you use "gf" is.  Thus using "gf" on "inits.h" will make MNV
look for "proto/inits.h", starting in the directory of the file.
   Without the "./", thus "proto", MNV would look in the "proto" directory
below the current directory.  And the current directory might not be where the
file that you are editing is located.

The 'path' option allows specifying the directories where to search for files
in many more ways.  See the help on the 'path' option.
   The 'isfname' option is used to decide which characters are included in the
file name, and which ones are not (e.g., the " character in the example
above).

When you know the file name, but it's not to be found in the file, you can
type it: >

	:find inits.h

MNV will then use the 'path' option to try and locate the file.  This is the
same as the ":edit" command, except for the use of 'path'.

To open the found file in a new window use CTRL-W f instead of "gf", or use
":sfind" instead of ":find".


A nice way to directly start MNV to edit a file somewhere in the 'path': >

	mnv "+find stdio.h"

This finds the file "stdio.h" in your value of 'path'.  The quotes are
necessary to have one argument |-+c|.

==============================================================================
*22.4*	The buffer list

The MNV editor uses the term buffer to describe a file being edited.
Actually, a buffer is a copy of the file that you edit.  When you finish
changing the buffer, you write the contents of the buffer to the file.
Buffers not only contain file contents, but also all the marks, settings, and
other stuff that goes with it.


HIDDEN BUFFERS

Suppose you are editing the file one.txt and need to edit the file two.txt.
You could simply use ":edit two.txt", but since you made changes to one.txt
that won't work.  You also don't want to write one.txt yet.  MNV has a
solution for you: >

	:hide edit two.txt

The buffer "one.txt" disappears from the screen, but MNV still knows that you
are editing this buffer, so it keeps the modified text.  This is called a
hidden buffer: The buffer contains text, but you can't see it.
   The argument of ":hide" is another command.  ":hide" makes that command
behave as if the 'hidden' option was set.  You could also set this option
yourself.  The effect is that when any buffer is abandoned, it becomes hidden.
   Be careful!  When you have hidden buffers with changes, don't exit MNV
without making sure you have saved all the buffers.


INACTIVE BUFFERS

When a buffer has been used once, MNV remembers some information about it.
When it is not displayed in a window and it is not hidden, it is still in the
buffer list.  This is called an inactive buffer.  Overview:

	Active		Appears in a window, text loaded.
	Hidden		Not in a window, text loaded.
	Inactive	Not in a window, no text loaded.

The inactive buffers are remembered, because MNV keeps information about them,
like marks.  And remembering the file name is useful too, so that you can see
which files you have edited.  And edit them again.


LISTING BUFFERS

View the buffer list with this command: >

	:buffers

A command which does the same, is not so obvious to list buffers, but is much
shorter to type: >

	:ls

The output could look like this:

  1 #h   "help.txt"			line 62 ~
  2 %a + "usr_21.txt"			line 1 ~
  3      "usr_toc.txt"			line 1 ~

The first column contains the buffer number.  You can use this to edit the
buffer without having to type the name, see below.
   After the buffer number come the flags.  Then the name of the file
and the line number where the cursor was the last time.
   The flags that can appear are these (from left to right):

	u	Buffer is unlisted |unlisted-buffer|.
	 %	Current buffer.
	 #	Alternate buffer.
	  a	Buffer is loaded and displayed.
	  h	Buffer is loaded but hidden.
	   =	Buffer is read-only.
	   -	Buffer is not modifiable, the 'modifiable' option is off.
	    +	Buffer has been modified.


EDITING A BUFFER

You can edit a buffer by its number.  That avoids having to type the file
name: >

	:buffer 2

But the only way to know the number is by looking in the buffer list.  You can
use the name, or part of it, instead: >

	:buffer help

MNV will find the best match for the name you type.  If there is only one
buffer that matches the name, it will be used.  In this case "help.txt".
   To open a buffer in a new window: >

	:sbuffer 3

This works with a name as well.


USING THE BUFFER LIST

You can move around in the buffer list with these commands:

	:bnext		go to next buffer
	:bprevious	go to previous buffer
	:bfirst		go to the first buffer
	:blast		go to the last buffer

To remove a buffer from the list, use this command: >

	:bdelete 3

Again, this also works with a name.
   If you delete a buffer that was active (visible in a window), that window
will be closed.  If you delete the current buffer, the current window will be
closed.  If it was the last window, MNV will find another buffer to edit.  You
can't be editing nothing!

	Note: Even after removing the buffer with ":bdelete" MNV still
	remembers it.  It's actually made "unlisted", it no longer appears in
	the list from ":buffers".  The ":buffers!" command will list unlisted
	buffers (yes, MNV can do the impossible).  To really make MNV forget
	about a buffer, use ":bwipe".  Also see the 'buflisted' option.

==============================================================================

Next chapter: |usr_23.txt|  Editing other files

Copyright: see |manual-copyright|  mnv:tw=78:ts=8:noet:ft=help:norl: