robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
715d8887ec
master
1*usr_31.txt* Nvim 2 3 4 VIM USER MANUAL by Bram Moolenaar 5 6 7 Exploiting the GUI 8 9 10Vim works well in a terminal, but the GUI has a few extra items. A file 11browser can be used for commands that use a file. A dialog to make a choice 12between alternatives. Use keyboard shortcuts to access menu items quickly. 13 14|31.1| The file browser 15|31.2| Confirmation 16|31.3| Menu shortcuts 17|31.4| Vim window position and size 18|31.5| Various 19 20 Next chapter: |usr_32.txt| The undo tree 21 Previous chapter: |usr_30.txt| Editing programs 22Table of contents: |usr_toc.txt| 23 24============================================================================== 25*31.1* The file browser 26 27You can open the current directory with: > 28 29 :browse edit 30 31The same works when opening a split or tabpage: > 32 33 :browse split 34 :browse vsplit 35 :browse tabedit 36 :browse tabnew 37 38By default this is handled by the builtin |dir| plugin. To use a third-party 39directory browser instead, see |dir-disable|. Use the dir browser's mappings 40to open a file. 41 42When a file or directory argument is given, the command is executed normally. 43For example: > 44 45 :browse edit /etc 46 47============================================================================== 48*31.2* Confirmation 49 50Vim protects you from accidentally overwriting a file and other ways to lose 51changes. If you do something that might be a bad thing to do, Vim produces an 52error message and suggests appending ! if you really want to do it. 53 To avoid retyping the command with the !, you can make Vim give you a 54dialog. You can then press "OK" or "Cancel" to tell Vim what you want. 55 For example, you are editing a file and made changes to it. You start 56editing another file with: > 57 58 :confirm edit foo.txt 59 60Vim will pop up a dialog that looks something like this: 61 62 +-----------------------------------+ 63 | | 64 | ? Save changes to "bar.txt"? | 65 | | 66 | YES NO CANCEL | 67 +-----------------------------------+ 68 69Now make your choice. If you do want to save the changes, select "YES". If 70you want to lose the changes for ever: "NO". If you forgot what you were 71doing and want to check what really changed use "CANCEL". You will be back in 72the same file, with the changes still there. 73 74Just like ":browse", the ":confirm" command can be prepended to most commands 75that edit another file. They can also be combined: > 76 77 :confirm browse edit 78 79This will produce a dialog when the current buffer was changed. Then it will 80pop up a file browser to select the file to edit. 81 82 Note: 83 In the dialog you can use the keyboard to select the choice. 84 Typically the <Tab> key and the cursor keys change the choice. 85 Pressing <Enter> selects the choice. This depends on the system 86 though. 87 88When you are not using the GUI, the ":confirm" command works as well. Instead 89of popping up a dialog, Vim will print the message at the bottom of the Vim 90window and ask you to press a key to make a choice. > 91 92 :confirm edit main.c 93< Save changes to "Untitled"? ~ 94 [Y]es, (N)o, (C)ancel: ~ 95 96You can now press the single key for the choice. You don't have to press 97<Enter>, unlike other typing on the command line. 98 99============================================================================== 100*31.3* Menu shortcuts 101 102The keyboard is used for all Vim commands. The menus provide a simple way to 103select commands, without knowing what they are called. But you have to move 104your hand from the keyboard and grab the mouse. 105 Menus can often be selected with keys as well. This depends on your 106system, but most often it works this way. Use the <Alt> key in combination 107with the underlined letter of a menu. For example, <A-w> (<Alt> and w) pops 108up the Window menu. 109 In the Window menu, the "split" item has the p underlined. To select it, 110let go of the <Alt> key and press p. 111 112After the first selection of a menu with the <Alt> key, you can use the cursor 113keys to move through the menus. <Right> selects a submenu and <left> closes 114it. <Esc> also closes a menu. <Enter> selects a menu item. 115 116There is a conflict between using the <Alt> key to select menu items, and 117using <Alt> key combinations for mappings. The 'winaltkeys' option tells Vim 118what it should do with the <Alt> key. 119 The default value "menu" is the smart choice: If the key combination is a 120menu shortcut it can't be mapped. All other keys are available for mapping. 121 The value "no" doesn't use any <Alt> keys for the menus. Thus you must use 122the mouse for the menus, and all <Alt> keys can be mapped. 123 The value "yes" means that Vim will use any <Alt> keys for the menus. Some 124<Alt> key combinations may also do other things than selecting a menu. 125 126============================================================================== 127*31.4* Vim window position and size 128 129To see the current Vim window position on the screen use: > 130 131 :winpos 132 133This will only work in the GUI. The output may look like this: 134 135 Window position: X 272, Y 103 ~ 136 137The position is given in screen pixels. Now you can use the numbers to move 138Vim somewhere else. For example, to move it to the left a hundred pixels: > 139 140 :winpos 172 103 141< 142 Note: 143 There may be a small offset between the reported position and where 144 the window moves. This is because of the border around the window. 145 This is added by the window manager. 146 147You can use this command in your startup script to position the window at a 148specific position. 149 150The size of the Vim window is computed in characters. Thus this depends on 151the size of the font being used. You can see the current size with this 152command: > 153 154 :set lines columns 155 156To change the size set the 'lines' and/or 'columns' options to a new value: > 157 158 :set lines=50 159 :set columns=80 160 161Obtaining the size works in a terminal just like in the GUI. Setting the size 162is not possible in most terminals. 163 164You can start the X-Windows version of gvim with an argument to specify the 165size and position of the window: > 166 167 gvim -geometry {width}x{height}+{x-offset}+{y-offset} 168 169{width} and {height} are in characters, {x-offset} and {y-offset} are in 170pixels. Example: > 171 172 gvim -geometry 80x25+100+300 173 174============================================================================== 175*31.5* Various 176 177You can use gvim to edit an e-mail message. In your e-mail program you must 178select gvim to be the editor for messages. When you try that, you will 179see that it doesn't work: The mail program thinks that editing is finished, 180while gvim is still running! 181 What happens is that gvim disconnects from the shell it was started in. 182That is fine when you start gvim in a terminal, so that you can do other work 183in that terminal. But when you really want to wait for gvim to finish, you 184must prevent it from disconnecting. The "-f" argument does this: > 185 186 gvim -f file.txt 187 188The "-f" stands for foreground. Now Vim will block the shell it was started 189in until you finish editing and exit. 190 191 192DELAYED START OF THE GUI 193 194On Unix it's possible to first start Vim in a terminal. That's useful if you 195do various tasks in the same shell. If you are editing a file and decide you 196want to use the GUI after all, you can start it with: > 197 198 :gui 199 200Vim will open the GUI window and no longer use the terminal. You can continue 201using the terminal for something else. The "-f" argument is used here to run 202the GUI in the foreground. You can also use ":gui -f". 203 204 205============================================================================== 206 207Next chapter: |usr_32.txt| The undo tree 208 209Copyright: see |manual-copyright| 210 211vim:tw=78:ts=8:noet:ft=help:norl: