Difference between revisions of "Vi"

From Freephile Wiki
Jump to navigation Jump to search
Line 29: Line 29:
  
 
=== [[VI Cheetsheet]] ===
 
=== [[VI Cheetsheet]] ===
* <kbd>Esc</kbd> - Escape to view-only mode.  Press ''Esc'' before using the following commands to get out of whatever mode you're already in.
+
* Esc - Escape to view-only mode.  Press ''Esc'' before using the following commands to get out of whatever mode you're already in.
* <code>:w !sudo tee %</code> force write file using sudo to 'tee' the standard output to the file descriptor
+
* i - Enter insert mode.  Place the cursor where you want to type and press ''i'' before typing.
* <kbd>i</kbd> - Enter insert mode.  Place the cursor where you want to type and press ''i'' before typing.
+
* x - Delete the character under the cursor.
* <kbd>x</kbd> - Delete the character under the cursor.
+
* dd - Delete the current line.
* <code>dd</code> - Delete the current line.
+
* :q! - Quit
* <code>:q!</code> - Quit
+
* :wq - Save and Quit
* <code>:wq</code> - Save and Quit
 
 
See our [[VI Cheetsheet]] or http://www.eec.com/business/vi.html for more
 
See our [[VI Cheetsheet]] or http://www.eec.com/business/vi.html for more
  

Revision as of 11:12, 20 June 2018

Learning VI[edit | edit source]

It's known for a relatively steep learning curve - because there are an unbelievable number of options for VI, but you can get by with a few basic commands (see below for the cheatsheet).

Also, the vim-common package includes the vimtutor command. This command allows you to go through an interactive tutorial. Either type <bash> vimtutor </bash> or <bash> man vimtutor </bash> for more information

In addition to the VIM, there is gvim which is the graphical version of vim. Use that too. After you read some of the resources listed here, you'll know how to use plugins for vim to do debugging, syntax highlighting, automatic docblocks, network and multiple file operations, lint syntax highlighting and code tag parsing with exuberant ctags.

Resources[edit | edit source]

Configuration[edit | edit source]

For configuring vim, including 'What is a modeline?' see these excellent references:

  • the Drupal website has a good collection of comments for configuring

vim for PHP http://drupal.org/node/29325

For an example of setting up additional syntax highlighting, see Syntax Highlighting

VI Cheetsheet[edit | edit source]

  • Esc - Escape to view-only mode. Press Esc before using the following commands to get out of whatever mode you're already in.
  • i - Enter insert mode. Place the cursor where you want to type and press i before typing.
  • x - Delete the character under the cursor.
  • dd - Delete the current line.
  • :q! - Quit
  • :wq - Save and Quit

See our VI Cheetsheet or http://www.eec.com/business/vi.html for more

VI Improved[edit | edit source]

On modern systems vim is actually the package that is installed because it succeeds the predecessor 'vi' There are many other vim-related packages. Check if vi is a symbolic link to vim (file `which vi`), and if not then sudo apt-get install vim.