About

Advanced Edit provides convenience commands, shortcuts and completion for programming.

If you get more productive and you enjoy editing source code more that you did before, all of this without even remembering that you're using Advanced Edit, then the script has fullfilled its purpose.

Download

aedit.vim (24K), changelog.txt (1K)

Features

Generic

Brace completion
Typing an opening brace will automatically append a closing brace. If you typed the opening brace by mistake, use Backspace to delete it and the closing brace will be deleted automatically.
Punctuation completion
In languages that use ; as the ending of a statement, the ; will be automatically appended where appropiate.
Use Alt-), Alt-], Alt-}, Alt-; or Alt-, to append ), ], }, ; or , respectively at the end of the line.
Word completion
The Tab key will present you with a completion menu formed by the words in the currently opened buffers.
Block completion
Use Alt-/ to complete a block. For example, if you're in a language in which blocks are formed by a { ... } construct (such as PHP or C), this command will automatically append both braces and put the cursor between them, with an increased indent. The same applies for other supported languages and markup, such as XML, where a block can be formed by an opening and a closing tag; just write the opening <tag> and the closing </tag> will automatically be appended by this command. It can also be used with "case" constructs.
Use Alt-Shift-/ to do the same as with Alt-/, but with opening braces appearing on the same line.
Use Alt-{ in visual mode to enclose the selection in a { ... } block.
Use Alt-/ in visual mode to comment the selection.
Use Alt-' in visual mode to cut the contents of the selection and automatically use it as a body for the next <tag> that you write.
Template expansion
Use the Spacebar key to expand a template. Templates are small snippets of text that, when expanded, are replaced by longer constructs.
Line movement
Alt-Up and Alt-Down will move the current line up or down, from insert and normal mode.
Jumps
Use Ctrl-CR to jump to the next line, from wherever you are in the current line.
Use Ctrl-Shift-CR to jump to the next line and raise the indent by one level.
Use Shift-CR to jump to the previous line.
Use Ctrl-A or Ctrl-E to move the cursor to the first non-space character or the last character in the line, respectively.
Smart Home key
The Home key will move the cursor to the first non-space character in the line. If you wish to move to the first character, whatever the character is, use Shift-Home instead.
Indenting
Use Tab or Shift-Tab in visual mode to indent or dedent the selected lines, respectively.
Shortcuts
Use F2 to toggle search highlighting.
Use Alt-N to toggle line numbering.
Use Alt-A to toggle word wrapping.
Use Ctrl-Q to toggle NERD tree.
Use Tab in normal mode to switch between windows.
Use Alt-D to delete the rest of the word under the cursor.
Use Alt-! to execute the last ! command.
Use Alt-: to execute the last : command.
Use Alt-W to write the file if it was changed, or Alt-Shift-W to write the file regardless of its state.
Use Alt-Q to quit, or Alt-Shift-Q to quit without any prompts.

PHP

PHP tag
Use Alt-. to insert a <?php ... ?> construct.

HTML

Tag features
If you write an opening <tag>, it will automatically be closed.
After writing an opening <tag>, use > to place the closing tag on the next line and position the cursor between the opening and closing tags.

MXML

Automatic capitalization
If you use the "mx" template, the first letter following the : sign will automatically be capitalized.

Templates

Following is a list of default templates. To define your own template, edit your .vimrc file and add g:template definitions in the form of let g:template{'filetype'}{'name'} = "expansion". For examples on how to write templates, please refer to the source code.

Generic

Name Expansion
f function with the opening brace on the same line, where applicable.
ff function with the opening brace on the next line, where applicable.
r return

Base

Name Expansion
thtml, tht HTML 4.01 template.
txhtml, thtt XHTML 1.0 template.
txml, tx XML template.
tmxml, tmx MXML template.
css CSS <link>.
js JavaScript <script> tag with a src attribute.

PHP

Name Expansion
cl class
ex extends
n new
t $this
n new
st static
pb public
pv private
pt protected
e echo
v var
gl global
fe foreach
wh while
sw switch
cs case
csd default
ar array
rq require
rqo require_once
dn dirname(__FILE__)
p <? ... ?>
pe <?= ... ?>
srv $_SERVER
def define
lab <label>
inp <input>
sel <select>

JavaScript

Name Expansion
t this
m method with { on the next line.
mm method with { on the same line.

MXML

Name Expansion
mx <mx:... />
as <mx:Script source="...">
scr <mx:Script>...</mx:Script>
css <mx:Style source="...">
st <mx:Style>...</mx:Style>
mxp <mx:Panel>...</mx:Panel>

Python

Name Expansion
cl class
s, t self
fi def __init__(self)
p pass