Moved to Vundle

Adopted vim-templates plugin, instead of homegrown skeleton
This commit is contained in:
Andrea Mistrali 2015-01-09 15:02:11 +00:00
parent 4671504dd5
commit 7e6736fbef
129 changed files with 29294 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,32 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=2771
Conque is a Vim plugin which allows you to run interactive programs, such as bash on linux or powershell.exe on Windows, inside a Vim buffer. In other words it is a terminal emulator which uses a Vim buffer to display the program output.
== WEBSITE ==
For more information http://code.google.com/p/conque/
== SCREENSHOTS ==
http://Conque.googlecode.com/svn/wiki/screenshot/unix.jpg
http://Conque.googlecode.com/svn/wiki/screenshot/windows.jpg
== USAGE ==
Type :ConqueTerm <command> to run your command in vim, for example:
:ConqueTerm bash
:ConqueTerm mysql -h localhost -u joe -p sock_collection
:ConqueTerm Powershell.exe
:ConqueTerm C:\Python27\python.exe
To open ConqueTerm in a new horizontal or vertical buffer use:
:ConqueTermSplit <command>
:ConqueTermVSplit <command>
:ConqueTermTab <command>
All text typed in insert mode will be sent to your shell. Use the <F9> key to send a visual selection from any buffer to the shell.
For more help type :help ConqueTerm

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,646 @@
*ConqueTerm* Plugin to run a shell inside a Vim buffer
The ConqueTerm plugin will turn a Vim buffer into a terminal emulator, allowing
you to run and interact with a shell or shell application inside the buffer.
1. Installation |conque-term-setup|
1.1 Requirements for Unix |conque-term-requirements|
1.2 Requirements for Windows |conque-term-windows|
1.3 Installation |conque-term-installation|
2. Usage |conque-term-usage|
2.1 General Usage |conque-term-gen-usage|
2.2 Special keys |conque-term-special-keys|
2.2.1 Send text to Conque |conque-term-send|
2.2.2 Toggle terminal input mode |conque-term-input-mode|
2.2.3 Sending the <Esc> key press |conque-term-esc|
3. Configuration |conque-term-options|
3.1 General |conque-config-general|
3.1.1 Python version |ConqueTerm_PyVersion|
3.1.2 Fast mode |ConqueTerm_FastMode|
3.1.3 Color support |ConqueTerm_Color|
3.1.4 Session Support |ConqueTerm_SessionSupport|
3.1.5 Keep updating terminal buffer |ConqueTerm_ReadUnfocused|
3.1.6 Insert mode when entering buffer |ConqueTerm_InsertOnEnter|
3.1.7 Close buffer when program exits |ConqueTerm_CloseOnEnd|
3.1.8 Hide start messages |ConqueTerm_StartMessages|
3.1.9 Regex for highlighting your prompt |ConqueTerm_PromptRegex|
3.1.10 Syntax type |ConqueTerm_Syntax|
3.2 Keyboard |conque-config-keyboard|
3.2.1 The <Esc> key |ConqueTerm_EscKey|
3.2.2 Toggle terminal input mode |ConqueTerm_ToggleKey|
3.2.3 Enable <C-w> in insert mode |ConqueTerm_CWInsert|
3.2.4 Execute current file in Conque |ConqueTerm_ExecFileKey|
3.2.5 Send current file contents to Conque|ConqueTerm_SendFileKey|
3.2.6 Send selected text to Conque |ConqueTerm_SendVisKey|
3.2.7 Function Keys |ConqueTerm_SendFunctionKeys|
3.3 Unix |conque-config-unix|
3.3.1 Choose your terminal type |ConqueTerm_TERM|
3.4 Windows |conque-config-windows|
3.4.1 Python executable |ConqueTerm_PyExe|
3.4.2 Windows character code page |ConqueTerm_CodePage|
3.4.3 Terminal color method |ConqueTerm_ColorMode|
4. VimScript API |conque-term-api|
4.1 conque_term#open() |conque-term-open|
4.2 conque_term#subprocess() |conque-term-subprocess|
4.3 conque_term#get_instance() |conque-term-get-instance|
4.4 CONQUE_OBJECT.write() |conque-term-write|
4.5 CONQUE_OBJECT.writeln() |conque-term-writeln|
4.6 CONQUE_OBJECT.read() |conque-term-read|
4.7 CONQUE_OBJECT.set_callback() |conque-term-set-callback|
4.8 CONQUE_OBJECT.close() |conque-term-close|
4.9 Registering functions |conque-term-events|
5. Misc |conque-term-misc|
5.1 Known bugs |conque-term-bugs|
5.2 Contribute |conque-term-contribute|
5.3 Feedback |conque-term-feedback|
==============================================================================
1. Installation *conque-term-setup*
Conque is designed for both Unix and Windows operating systems, however the
requirements are slightly different. Please check section below corresponding
to your installed OS.
1.1 Requirements for Unix *conque-term-requirements*
* [G]Vim 7.0+ with +python and/or +python3
* Python 2.3+ and/or 3.x
* Unix-like OS: Linux, OS X, Solaris, Cygwin, etc
The most common stumbling block is getting a version of Vim which has the
python interface enabled. Most all software package managers will have a copy
of Vim with Python support, so that is often the easiest way to get it. If
you're compiling Vim from source, be sure to use the --enable-pythoninterp
option, or --enable-python3interp for Python 3. On OS X the best option is
MacVim, which installs with Python support by default.
1.2 Requirements for Windows *conque-term-windows*
* [G]Vim 7.3 with +python and/or +python3
* Python 2.7 and/or 3.1
* Modern Windows OS (XP or later)
Conque only officially supports the latest GVim 7.3 Windows installer
available at www.vim.org. If you are currently using Vim 7.2 or earlier you
will need to upgrade to 7.3 for Windows support. The Windows installer already
has the +python/+python3 interface built in.
The official 7.3 release of Vim for Windows only works with Python versions
2.7 and/or 3.1. You can download and install Python from their website
http://www.python.org/download
If you are compiling Vim + Python from source on Windows, the requirements
become only Vim 7.3+ and Python 2.7+.
1.3 Installation *conque-term-installation*
Download the latest vimball from http://conque.googlecode.com
Open the .vba file with Vim and run the following commands:
>
:so %
:q
<
That's it! The :ConqueTerm command will be available the next time you start
Vim. You can delete the .vba file when you've verified Conque was successfully
installed.
==============================================================================
2. Usage *conque-term-usage*
2.1 General Usage *conque-term-gen-usage*
Type :ConqueTerm <command> to launch an application in the current buffer. Eg:
>
:ConqueTerm bash
:ConqueTerm mysql -h localhost -u joe_lunchbox Menu
:ConqueTerm Powershell.exe
<
Use :ConqueTermSplit or :ConqueTermVSplit to open Conque in a new horizontal
or vertical buffer. Use :ConqueTermTab to open Conque in a new tab.
In insert mode you can interact with the shell as you would expect in a
normal terminal. All key presses will be sent to the terminal, including
control characters. See |conque-term-special-keys| for more information,
particularly regarding the <Esc> key.
In normal mode you can use Vim commands to browse your terminal output and
scroll back through the history. Most all Vim functionality will work, such
as searching, yanking or highlighting text.
2.2 Special keys *conque-term-special-keys*
There are several keys which can be configured to have special behavior with
Conque.
2.2.1 Send text to Conque *conque-term-send*
Conque gives you three different commands to send text from a different
buffer, probably a source code file, to the Conque terminal buffer. All three
are configurable to use your choice of key combinations.
To send a visually selected range of text to an existing terminal buffer,
press the <F9> key.
To send the entire contents of the file you are editing to an existing
terminal buffer, press the <F10> key.
Finally, to execute the current file in a new terminal buffer press the <F11>
key. This will split the screen with a new Conque buffer. The file you are
editing must be executable for this command to work.
See |conque-term-options| for information about configuring these commands.
2.2.2 Toggle terminal input mode *conque-term-input-mode*
If you want to use insert mode to edit the terminal screen, press <F8>. You
will now be able to edit the terminal output freely without your cursor
jumping the the active prompt line. This may be useful if you want to reformat
terminal output for readability.
While the terminal is paused new output will not be displayed on the screen
until you press <F8> again to resume.
You can configure Conque to use a different key with the |ConqueTerm_ToggleKey|
option.
2.2.3 Sending the <Esc> key press *conque-term-esc*
By default if you press the <Esc> key in a Conque buffer you will leave insert
mode. But what if you want the <Esc> character to be sent to your terminal?
There are two options. By default, pressing <Esc> twice will send one <Esc>
character to the terminal and you will remain in insert mode, while pressing
it once will leave insert mode.
Alternatively you can use the |ConqueTerm_EscKey| option to choose a
different key for leaving insert mode. If a custom key is set, then all <Esc>
key presses will be sent to the terminal.
2.3 Registering functions *conque-term-register*
Conque allows you to write your own VimScript functions which will be called
at certain events. See the API section |conque-term-events| for more.
==============================================================================
3. Options *conque-term-options*
You can set the following options in your .vimrc (default values shown)
3.1 General *conque-config-general*
3.1.1 Python version *ConqueTerm_PyVersion*
Conque will work with either Python 2.x or 3.x, assuming the interfaces have
been installed. By default it will try to use Python 2 first, then will try
Python 3. If you want Conque to use Python 3, set this variable to 3.
Note: even if you set this to 3, if you don't have the python3 interface
Conque will fall back to using Python 2.
>
let g:ConqueTerm_PyVersion = 2
<
3.1.2 Fast Mode *ConqueTerm_FastMode*
Disable features which could make Conque run slowly. This includes most
terminal colors and some unicode support. Set this to 1 to enable fast mode.
>
let g:ConqueTerm_FastMode = 0
<
3.1.3 Color support *ConqueTerm_Color*
Terminal colors have the potential to slow down terminal screen rendering,
depending on how many colors are used and how fast the computer is. This
option allows you to choose how much color support will be enabled.
If set to 0, terminal colors will be disabled. This will allow the terminal to
render most quickly. Syntax highlighting will still work. For example
highlighting quoted strings or MySQL output.
If set to 1, terminal colors will be enabled, but only for the most recent 200
lines of terminal output. Older output will be periodically stripped of color
highlighting to keep the display responsive.
If set to 2, terminal colors will always be enabled. If your programs don't
use color output very frequently this is a good choice.
Note: Color support is automatically disabled in "fast mode".
>
let g:ConqueTerm_Color = 1
<
3.1.4 Session Support *ConqueTerm_SessionSupport*
Vim's :mksession command allows you to save your current buffer configuration
to a file, which can be loaded at a later time after you've closed Vim.
By default, Conque buffers are not restored. This is mostly for safety
reasons; you may not want Vim to automatically re-run a destructive command.
However, if you're not working with missile launch code, and want Vim to
restart your Conque buffers when you load a session file, set this variable
to 1. Note your original subprocess and shell output will not be restored, but
the same command will be started in your buffer.
>
let g:ConqueTerm_SessionSupport = 0
<
3.1.5 Keep updating terminal buffer *ConqueTerm_ReadUnfocused*
If set to 1 then your Conque buffers will continue to update after you've
switched to another buffer.
Note: Conque buffers may continue to update, but they will not scroll down as
new lines are added beyond the bottom of the visible buffer area. This is a
limitation of the Vim scripting language for which I haven't found a
workaround.
>
let g:ConqueTerm_ReadUnfocused = 1
<
3.1.6 Insert mode when entering buffer *ConqueTerm_InsertOnEnter*
If set to 1 then you will automatically go into insert mode when you enter the
buffer. This diverges from normal Vim behavior. If 0 you will still be in
normal mode.
>
let g:ConqueTerm_InsertOnEnter = 0
<
3.1.7 Close buffer when program exits *ConqueTerm_CloseOnEnd*
If you want your terminal buffer to be closed and permanently deleted when the
program running inside of it exits, set this option to 1. Otherwise the buffer
will become a simple text buffer after the program exits, and you can edit the
program output in insert mode.
>
let g:ConqueTerm_CloseOnEnd = 0
<
3.1.8 Show start messages *ConqueTerm_StartMessages*
Display warning messages when starting up ConqueTerm if your system is
configured incorrectly.
>
let g:ConqueTerm_StartMessages = 1
<
3.1.9 Regex for highlighting your prompt *ConqueTerm_PromptRegex*
Use this regular expression for sytax highlighting your terminal prompt. Your
terminal will generally run faster if you use Vim highlighting instead of
terminal colors for your prompt. You can also use it to do more advanced
syntax highlighting for the prompt line.
>
let g:ConqueTerm_PromptRegex = '^\w\+@[0-9A-Za-z_.-]\+:[0-9A-Za-z_./\~,:-]\+\$'
<
3.1.10 Choose Vim syntax type *ConqueTerm_Syntax*
Set the buffer syntax. The default 'conque' has highlighting for MySQL, but
not much else.
>
let g:ConqueTerm_Syntax = 'conque'
<
3.2 Keyboard *conque-config-keyboard*
3.2.1 The <Esc> key *ConqueTerm_EscKey*
If a custom key is set, then all <Esc> key presses will be sent to the
terminal and you must use this custom key to leave insert mode. If left to the
default value of '<Esc>' then you must press it twice to send the escape
character to the terminal, while pressing it once will leave insert mode.
Note: You cannot use a key which is internally coded with the escape
character. This includes the <F-> keys and often the <A-> and <M-> keys.
Picking a control key, such as <C-k> will be your best bet.
>
let g:ConqueTerm_EscKey = '<Esc>'
<
3.2.2 Toggle terminal input mode *ConqueTerm_ToggleKey*
Press this key to pause terminal input and output display. You will then be
able to edit the terminal screen as if it were a normal text buffer. Press
this key again to resume terminal mode.
>
let g:ConqueTerm_ToggleKey = '<F8>'
<
3.2.3 Enable <C-w> in insert mode *ConqueTerm_CWInsert*
If set to 1 then you can leave the Conque buffer using the <C-w> commands
while you're still in insert mode. If set to 0 then the <C-w> character will
be sent to the terminal. If both this option and ConqueTerm_InsertOnEnter are
set you can go in and out of the terminal buffer while never leaving insert
mode.
>
let g:ConqueTerm_CWInsert = 0
<
3.2.4 Execute current file in Conque *ConqueTerm_ExecFileKey*
Press this key to execute the file you're currently editing in a Conque
buffer. Is equivelent to running the command :ConqueTermSplit YOUR_FILE. Your
file must be executable for this command to work correctly.
>
let g:ConqueTerm_ExecFileKey = '<F11>'
<
3.2.5 Send current file contents to Conque *ConqueTerm_SendFileKey*
Press this key to send your entire file contents to the most recently opened
Conque buffer as keyboard input.
>
let g:ConqueTerm_SendFileKey = '<F10>'
<
3.2.6 Send selected text to Conque *ConqueTerm_SendVisKey*
Use this key to send the currently selected text to the most recently created
Conque buffer.
>
let g:ConqueTerm_SendVisKey = '<F9>'
<
3.2.7 Function Keys *ConqueTerm_SendFunctionKeys*
By default, function keys (the F1-F12 row at the top of your keyboard) are not
passed to the terminal. Set this option to 1 to send these key events.
Note: Unless you configured |ConqueTerm_SendVisKey| and |ConqueTerm_ToggleKey|
to use different keys, <F8> and <F9> will not be sent to the terminal even if
you set this option to 1.
>
let g:ConqueTerm_SendFunctionKeys = 0
<
3.3 Unix *conque-config-unix*
3.3.1 Choose your terminal type, Unix ONLY *ConqueTerm_TERM*
Use this option to tell Conque what type of terminal it should identify itself
as. Conque officially uses the more limited VT100 terminal type for
developement and testing, although it supports some more advanced features
such as colors and title strings.
You can change this setting to a more advanced type, namely 'xterm', but your
results may vary depending on which programs you're running.
>
let g:ConqueTerm_TERM = 'vt100'
<
3.4 Windows *conque-config-windows*
3.4.1 Python executable, Windows ONLY *ConqueTerm_PyExe*
The Windows version of Conque needs to know the path to the python.exe
executable for the version of Python Conque is using. If you installed Python
in the default location, or added the Python directory to your system path,
Conque should be able to find python.exe without you changing this variable.
For example, you might set this to 'C:\Program Files\Python27\python.exe'
>
let g:ConqueTerm_PyExe = ''
<
3.4.2 Windows character code page *ConqueTerm_CodePage*
Set the "code page" Windows will use for your console. Leave this value set to
zero to use the environment code page.
Note: Displaying unicode characters on Conque for Windows needs work.
>
let g:ConqueTerm_CodePage = 0
<
3.4.3 Terminal color method, Windows ONLY *ConqueTerm_ColorMode*
Vim syntax highlighting by coordinate (e.g. the 3-7th characters on the 42nd
line) can be very slow. If you set this variable to 'conceal', you can use
the new conceal feature to render terminal colors. Requires Vim 7.3 and only
works on the Windows version of Conque. This will make colors render faster,
however it will also add hidden characters to the screen, which may be
annoying if you're copying and pasting terminal output out of the Conque
buffer. Set this to an empty string '' to disable concealed highlighting.
>
let g:ConqueTerm_ColorMode = 'conceal'
<
==============================================================================
4. VimScript API (Beta) *conque-term-api*
The Conque scripting API allows you to create and interact with Conque
terminals with the VimScript language. This API is still in beta stage.
4.1 conque_term#open({command}, [buf_opts], [remain]) *conque-term-open*
The open() function will create a new terminal buffer and start your command.
The {command} must be an executable, either an absolute path or relative to
your system path.
You can pass in a list of vim commands [buf_opts] which will be executed after
the new buffer is created but before the command is started. These are
typically commands to alter the size, position or configuration of the buffer
window.
Note: If you don't pass in a command such as 'split', the terminal will open
in the current buffer.
If you don't want the new terminal buffer to become the new active buffer, set
[remain] to 1. Only works if you create a split screen using [options].
Returns a Conque terminal object.
Examples:
>
let my_terminal = conque_term#open('/bin/bash')
let my_terminal = conque_term#open('ipython', ['split', 'resize 20'], 1)
<
4.2 conque_term#subprocess({command}) *conque-term-subprocess*
Starts a new subprocess with your {command}, but no terminal buffer is ever
created. This may be useful if you need asynchronous interaction with a
subprocess, but want to handle the output on your own.
Returns a Conque terminal object.
Example:
>
let my_subprocess = conque_term#subprocess('tail -f /var/log/foo.log')
<
4.3 conque_term#get_instance( [terminal_number] ) *conque-term-get-instance*
Use the get_instance() function to retrieve an existing terminal object. The
terminal could have been created either with the user command :ConqueTerm or
with an API call to conque_term#open() or subprocess().
Use the optional [terminal_number] to retrieve a specific terminal instance.
Otherwise if the current buffer is a Conque terminal, it will be returned,
else the most recently created terminal. The terminal number is what you see
at the end of a terminal buffer name, e.g. "bash - 2".
Returns a Conque terminal object.
Example:
>
nnoremap <F4> :call conque_term#get_instance().writeln('clear')<CR>
<
4.4 CONQUE_OBJECT.write({text}) *conque-term-write*
Once you have a terminal object from open(), subprocess() or get_instance()
you can send text input to it with the write() method.
No return value.
Examples:
>
call my_terminal.write("whoami\n")
call my_terminal.write("\<C-c>")
<
4.5 CONQUE_OBJECT.writeln({text}) *conque-term-writeln*
The same as write() except adds a \n character to the end if your input.
Examples:
>
call my_subprocess.writeln('make')
<
4.6 CONQUE_OBJECT.read( [timeout], [update_buffer] ) *conque-term-read*
Read new output from a Conque terminal subprocess. New output will be returned
as a string, and the terminal buffer will also be updated by default.
If you are reading immediately after calling the write() method, you may want
to wait [timeout] milliseconds for output to be ready.
If you want to prevent the output from being displayed in the terminal buffer,
set [update_buffer] to 0. This option has no effect if the terminal was
created with the subprocess() function, since there never is a buffer to
update.
Returns output string.
Note: The terminal buffer will not automatically scroll down if the new output
extends beyond the bottom of the visible buffer. Vim doesn't allow "unfocused"
buffers to be scrolled at the current version, although hopefully this will
change.
Examples:
>
call my_terminal.writeln('whoami')
let output = my_terminal.read(500)
call my_terminal.writeln('ls -lha')
let output = my_terminal.read(1000, 1)
<
4.7 CONQUE_OBJECT.set_callback( {funcname} ) *conque-term-set-callback*
Register a callback function for this subprocess instance. This function will
automatically be called whenever new output is available. Only practical with
subprocess() objects.
Conque checkes for new subprocess output once a second when Vim is idle. If
new output is found your function will be called.
Pass in the callback function name {funcname} as a string.
No return value.
Note: this method requires the g:ConqueTerm_ReadUnfocused option to be set.
Note: this method is experimental, results may vary.
Example:
>
let sp = conque_term#subprocess('tail -f /home/joe/log/error_log')
function! MyErrorAlert(output)
echo a:output
endfunction
call sp.set_callback('MyErrorAlert')
<
4.8 CONQUE_OBJECT.close() *conque-term-close*
Kill your terminal subprocess. Sends the ABORT signal. You probably want to
close your subprocess in a more graceful manner with the write() method, but
this can be used when needed. Does not close the terminal buffer, if it
exists.
This method will be called on all existing Conque subprocesses when Vim exits.
Example:
>
let term = conque_term#open('ping google.com', ['belowright split'])
call term.read(5000)
call term.close()
<
4.9 Registering functions *conque-term-events*
Conque provides the option to register callback functions which will be
executed at several different events. The currently available events are:
after_startup After your application has loaded into the buffer.
buffer_enter When you switch to a Conque buffer.
buffer_leave When you leave a Conque buffer.
You may use the function conque_term#register_function(event, function_name)
to add additional hooks at a particular event. The second argument should be
the name of a callback function which has one parameter, the current
terminal object (see|conque-term-api|for more about terminal objects).
For example:
>
function MyConqueStartup(term)
" set buffer syntax using the name of the program currently running
let syntax_associations = { 'ipython': 'python', 'irb': 'ruby' }
if has_key(syntax_associations, a:term.program_name)
execute 'setlocal syntax=' . syntax_associations[a:term.program_name]
else
execute 'setlocal syntax=' . a:term.program_name
endif
" shrink window height to 10 rows
resize 10
" silly example of terminal api usage
if a:term.program_name == 'bash'
call a:term.writeln('svn up ~/projects/*')
endif
endfunction
call conque_term#register_function('after_startup', 'MyConqueStartup')
<
==============================================================================
5. Misc *conque-term-misc*
5.1 Known bugs *conque-term-bugs*
The following are known limitations:
- Font/color highlighting is imperfect and slow. If you don't care about
color in your shell, set g:ConqueTerm_Color = 0 in your .vimrc
- Conque only supports the extended ASCII character set for input, not utf-8.
- VT100 escape sequence support is not complete.
- Alt/Meta key support in Vim isn't great in general, and conque is no
exception. Pressing <Esc><Esc>x or <Esc><M-x> instead of <M-x> works in
most cases.
5.2 Contribute *conque-term-contribute*
The two contributions most in need are improvements to Vim itself. I currently
use hacks to capture key press input from the user, and to poll the terminal
for more output. The Vim todo.txt document lists proposed improvements to give
users this behavior without hacks. Having a key press event should allow
Conque to work with multi- byte input. If you are a Vim developer, please
consider prioritizing these two items:
- todo.txt (Autocommands, line ~3137)
8 Add an event like CursorHold that is triggered repeatedly, not just
once after typing something.
5.3 Feedback *conque-term-feedback*
Bugs, suggestions and patches are all welcome.
For more information visit http://conque.googlecode.com
Check out the latest from svn at http://conque.googlecode.com/svn/trunk/
vim:tw=78:ts=8:ft=help:norl:

View File

@ -0,0 +1,52 @@
ConqueTerm conque_term.txt /*ConqueTerm*
ConqueTerm_CWInsert conque_term.txt /*ConqueTerm_CWInsert*
ConqueTerm_CloseOnEnd conque_term.txt /*ConqueTerm_CloseOnEnd*
ConqueTerm_CodePage conque_term.txt /*ConqueTerm_CodePage*
ConqueTerm_Color conque_term.txt /*ConqueTerm_Color*
ConqueTerm_ColorMode conque_term.txt /*ConqueTerm_ColorMode*
ConqueTerm_EscKey conque_term.txt /*ConqueTerm_EscKey*
ConqueTerm_ExecFileKey conque_term.txt /*ConqueTerm_ExecFileKey*
ConqueTerm_FastMode conque_term.txt /*ConqueTerm_FastMode*
ConqueTerm_InsertOnEnter conque_term.txt /*ConqueTerm_InsertOnEnter*
ConqueTerm_PromptRegex conque_term.txt /*ConqueTerm_PromptRegex*
ConqueTerm_PyExe conque_term.txt /*ConqueTerm_PyExe*
ConqueTerm_PyVersion conque_term.txt /*ConqueTerm_PyVersion*
ConqueTerm_ReadUnfocused conque_term.txt /*ConqueTerm_ReadUnfocused*
ConqueTerm_SendFileKey conque_term.txt /*ConqueTerm_SendFileKey*
ConqueTerm_SendFunctionKeys conque_term.txt /*ConqueTerm_SendFunctionKeys*
ConqueTerm_SendVisKey conque_term.txt /*ConqueTerm_SendVisKey*
ConqueTerm_SessionSupport conque_term.txt /*ConqueTerm_SessionSupport*
ConqueTerm_StartMessages conque_term.txt /*ConqueTerm_StartMessages*
ConqueTerm_Syntax conque_term.txt /*ConqueTerm_Syntax*
ConqueTerm_TERM conque_term.txt /*ConqueTerm_TERM*
ConqueTerm_ToggleKey conque_term.txt /*ConqueTerm_ToggleKey*
conque-config-general conque_term.txt /*conque-config-general*
conque-config-keyboard conque_term.txt /*conque-config-keyboard*
conque-config-unix conque_term.txt /*conque-config-unix*
conque-config-windows conque_term.txt /*conque-config-windows*
conque-term-api conque_term.txt /*conque-term-api*
conque-term-bugs conque_term.txt /*conque-term-bugs*
conque-term-close conque_term.txt /*conque-term-close*
conque-term-contribute conque_term.txt /*conque-term-contribute*
conque-term-esc conque_term.txt /*conque-term-esc*
conque-term-events conque_term.txt /*conque-term-events*
conque-term-feedback conque_term.txt /*conque-term-feedback*
conque-term-gen-usage conque_term.txt /*conque-term-gen-usage*
conque-term-get-instance conque_term.txt /*conque-term-get-instance*
conque-term-input-mode conque_term.txt /*conque-term-input-mode*
conque-term-installation conque_term.txt /*conque-term-installation*
conque-term-misc conque_term.txt /*conque-term-misc*
conque-term-open conque_term.txt /*conque-term-open*
conque-term-options conque_term.txt /*conque-term-options*
conque-term-read conque_term.txt /*conque-term-read*
conque-term-register conque_term.txt /*conque-term-register*
conque-term-requirements conque_term.txt /*conque-term-requirements*
conque-term-send conque_term.txt /*conque-term-send*
conque-term-set-callback conque_term.txt /*conque-term-set-callback*
conque-term-setup conque_term.txt /*conque-term-setup*
conque-term-special-keys conque_term.txt /*conque-term-special-keys*
conque-term-subprocess conque_term.txt /*conque-term-subprocess*
conque-term-usage conque_term.txt /*conque-term-usage*
conque-term-windows conque_term.txt /*conque-term-windows*
conque-term-write conque_term.txt /*conque-term-write*
conque-term-writeln conque_term.txt /*conque-term-writeln*

View File

@ -0,0 +1,113 @@
" FILE: syntax/conque_term.vim {{{
" AUTHOR: Nico Raffo <nicoraffo@gmail.com>
" WEBSITE: http://conque.googlecode.com
" MODIFIED: 2011-08-12
" VERSION: 2.2, for Vim 7.0
" LICENSE:
" Conque - Vim terminal/console emulator
" Copyright (C) 2009-__YEAR__ Nico Raffo
"
" MIT License
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to deal
" in the Software without restriction, including without limitation the rights
" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
" copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
" THE SOFTWARE.
" }}}
" *******************************************************************************************************************
" MySQL *************************************************************************************************************
" *******************************************************************************************************************
" TODO Move these to syntax which is only executed for mysql
"syn match MySQLTableBodyG "^\s*\w\+:\(.\+\)\=$" contains=MySQLTableHeadG,MySQLNullG,MySQLBool,MySQLNumberG,MySQLStorageClass oneline skipwhite skipnl
"syn match MySQLTableHeadG "^\s*\w\+:" contains=MySQLTableColon skipwhite contained
"syn match MySQLTableColon ":" contained
syn match MySQLTableHead "^ *|.*| *$" nextgroup=MySQLTableDivide contains=MySQLTableBar oneline skipwhite skipnl
syn match MySQLTableBody "^ *|.*| *$" nextgroup=MySQLTableBody,MySQLTableEnd contains=MySQLTableBar,MySQLNull,MySQLBool,MySQLNumber,MySQLStorageClass oneline skipwhite skipnl
syn match MySQLTableEnd "^ *+[+=-]\++ *$" oneline
syn match MySQLTableDivide "^ *+[+=-]\++ *$" nextgroup=MySQLTableBody oneline skipwhite skipnl
syn match MySQLTableStart "^ *+[+=-]\++ *$" nextgroup=MySQLTableHead oneline skipwhite skipnl
syn match MySQLNull " NULL " contained contains=MySQLTableBar
syn match MySQLStorageClass " PRI " contained
syn match MySQLStorageClass " MUL " contained
syn match MySQLStorageClass " UNI " contained
syn match MySQLStorageClass " CURRENT_TIMESTAMP " contained
syn match MySQLStorageClass " auto_increment " contained
syn match MySQLTableBar "|" contained
syn match MySQLNumber "|\? *\d\+\(\.\d\+\)\? *|" contained contains=MySQLTableBar
syn match MySQLQueryStat "^\d\+ rows\? in set.*" oneline
syn match MySQLPromptLine "^.\?mysql> .*$" contains=MySQLKeyword,MySQLPrompt,MySQLString oneline
syn match MySQLPromptLine "^ -> .*$" contains=MySQLKeyword,MySQLPrompt,MySQLString oneline
syn match MySQLPrompt "^.\?mysql>" contained oneline
syn match MySQLPrompt "^ ->" contained oneline
syn case ignore
syn keyword MySQLKeyword select count max sum avg date show table tables status like as from left right outer inner join contained
syn keyword MySQLKeyword where group by having limit offset order desc asc show contained and interval is null on
syn case match
syn region MySQLString start=+'+ end=+'+ skip=+\\'+ contained oneline
syn region MySQLString start=+"+ end=+"+ skip=+\\"+ contained oneline
syn region MySQLString start=+`+ end=+`+ skip=+\\`+ contained oneline
hi def link MySQLPrompt Identifier
hi def link MySQLTableHead Title
hi def link MySQLTableBody Normal
hi def link MySQLBool Boolean
hi def link MySQLStorageClass StorageClass
hi def link MySQLNumber Number
hi def link MySQLKeyword Keyword
hi def link MySQLString String
" terms which have no reasonable default highlight group to link to
hi MySQLTableHead term=bold cterm=bold gui=bold
if &background == 'dark'
hi MySQLTableEnd term=NONE cterm=NONE gui=NONE ctermfg=238 guifg=#444444
hi MySQLTableDivide term=NONE cterm=NONE gui=NONE ctermfg=238 guifg=#444444
hi MySQLTableStart term=NONE cterm=NONE gui=NONE ctermfg=238 guifg=#444444
hi MySQLTableBar term=NONE cterm=NONE gui=NONE ctermfg=238 guifg=#444444
hi MySQLNull term=NONE cterm=NONE gui=NONE ctermfg=238 guifg=#444444
hi MySQLQueryStat term=NONE cterm=NONE gui=NONE ctermfg=238 guifg=#444444
elseif &background == 'light'
hi MySQLTableEnd term=NONE cterm=NONE gui=NONE ctermfg=247 guifg=#9e9e9e
hi MySQLTableDivide term=NONE cterm=NONE gui=NONE ctermfg=247 guifg=#9e9e9e
hi MySQLTableStart term=NONE cterm=NONE gui=NONE ctermfg=247 guifg=#9e9e9e
hi MySQLTableBar term=NONE cterm=NONE gui=NONE ctermfg=247 guifg=#9e9e9e
hi MySQLNull term=NONE cterm=NONE gui=NONE ctermfg=247 guifg=#9e9e9e
hi MySQLQueryStat term=NONE cterm=NONE gui=NONE ctermfg=247 guifg=#9e9e9e
endif
" *******************************************************************************************************************
" Bash **************************************************************************************************************
" *******************************************************************************************************************
" Typical Prompt
if g:ConqueTerm_PromptRegex != ''
silent execute "syn match ConquePromptLine '" . g:ConqueTerm_PromptRegex . ".*$' contains=ConquePrompt,ConqueString oneline"
silent execute "syn match ConquePrompt '" . g:ConqueTerm_PromptRegex . "' contained oneline"
hi def link ConquePrompt Identifier
endif
" Strings
syn region ConqueString start=+'+ end=+'+ skip=+\\'+ contained oneline
syn region ConqueString start=+"+ end=+"+ skip=+\\"+ contained oneline
syn region ConqueString start=+`+ end=+`+ skip=+\\`+ contained oneline
hi def link ConqueString String
" vim: foldmethod=marker

View File

@ -0,0 +1,17 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=2324
This plugin provides commands and key mappings to quickly align and format text. Text can be easily reformatted and aligned to either left or right margin or justified to both margins or centered. The text formatting commands provided by this plugin are a bit more automatic and more intelligent than those integrated to Vim. Together they make more powerful command set for formatting text.
Manual is included, just type
:help textformat.txt
Default keymappings:
\al Left-align and reformat
\ar Right-align
\aj Left-right justify and reformat
\ac Center lines
The prefix key is actually <Leader> key. It's backlash by default but it is configurable.

View File

@ -0,0 +1,610 @@
" Text formatter plugin for Vim text editor
"
" Version: 2.1
" Last Change: 2008-09-13
" Maintainer: Teemu Likonen <tlikonen@iki.fi>
" License: This file is placed in the public domain.
" GetLatestVimScripts: 2324 1 :AutoInstall: TextFormat
"{{{1 The beginning stuff
if &compatible
finish
endif
let s:save_cpo = &cpo
set cpo&vim
" Constant variables(s) {{{1
let s:default_width = 80
function! s:Align_Range_Left(...) range "{{{1
" The optional parameter is the left indent. If it is not given we
" detect the indent used in the buffer.
if a:0 && a:1 >= 0
" The parameter was given so we just use that as the left
" indent.
let l:leading_ws = s:Retab_Indent(a:1)
for l:line in range(a:firstline,a:lastline)
let l:line_string = getline(l:line)
let l:line_replace = s:Align_String_Left(l:line_string)
if &formatoptions =~ 'w' && l:line_string =~ '\m\s$'
" Preserve trailing whitespace because fo=~w
let l:line_replace .= ' '
endif
if l:line_replace =~ '\m^\s*$'
call setline(l:line,'')
else
call setline(l:line,l:leading_ws.l:line_replace)
endif
endfor
else
" The parameter was not given so we detect each paragraph's
" indent.
let l:line = a:firstline
while l:line <= a:lastline
let l:line_string = getline(l:line)
if l:line_string =~ '\m^\s*$'
" The line is empty or contains only
" whitespaces so print empty line and
" continue.
call setline(l:line,'')
let l:line += 1
continue
endif
" Paragraph (or the whole line range) begins here so
" get the indent of the first line and print the line.
let l:leading_ws = s:Retab_Indent(indent(l:line))
let l:line_replace = s:Align_String_Left(l:line_string)
if &formatoptions =~ 'w' && l:line_string =~ '\m\s$'
let l:line_replace .= ' '
endif
call setline(l:line,l:leading_ws.l:line_replace)
let l:line += 1
" If fo=~w, does the paragraph end here? If yes,
" continue to next round and find a new first line.
if &formatoptions =~ 'w' && l:line_string =~ '\m\S$'
continue
endif
" If fo=~2 get the indent of the second line
if &formatoptions =~ '2'
let l:leading_ws = s:Retab_Indent(indent(l:line))
endif
" This loop will go through all the lines in the
" paragraph (or till the a:lastline) - starting from
" the second line.
while l:line <= a:lastline && getline(l:line) !~ '\m^\s*$'
let l:line_string = getline(l:line)
let l:line_replace = s:Align_String_Left(l:line_string)
if &formatoptions =~ 'w'
if l:line_string =~ '\m\s$'
call setline(l:line,l:leading_ws.l:line_replace.' ')
let l:line += 1
continue
else
call setline(l:line,l:leading_ws.l:line_replace)
let l:line += 1
" fo=~w and paragraph ends
" here so we break the loop.
" The next line is new first
" line.
break
endif
else
call setline(l:line,l:leading_ws.l:line_replace)
let l:line += 1
endif
endwhile
endwhile
endif
endfunction
function! s:Align_Range_Right(width) "{{{1
let l:line_replace = s:Align_String_Right(getline('.'),a:width)
if &formatoptions =~ 'w' && getline('.') =~ '\m\s$'
let l:line_replace .= ' '
endif
if l:line_replace =~ '\m^\s*$'
" If line would be full of spaces just print empty line.
call setline(line('.'),'')
else
" Retab leading whitespaces
let l:leading_ws = s:Retab_Indent(strlen(substitute(l:line_replace,'\v^( *).*$','\1','')))
" Get the rest of the line
let l:line_replace = substitute(l:line_replace,'^ *','','')
call setline(line('.'),l:leading_ws.l:line_replace)
endif
endfunction
function! s:Align_Range_Justify(width, ...) range "{{{1
" If the optional second argument is given (and is non-zero) each
" paragraph's last line and range's last line is left-aligned.
if a:0 && a:1
let l:paragraph = 1
else
let l:paragraph = 0
endif
let l:line = a:firstline
while l:line <= a:lastline
let l:line_string = getline(l:line)
if l:line_string =~ '\m^\s*$'
" The line is empty or contains only
" whitespaces so print empty line and
" continue.
call setline(l:line,'')
let l:line += 1
continue
endif
" Paragraph (or the whole line range) begins here so
" get the indent of the first line and print the line.
let l:indent = indent(l:line)
let l:width = a:width - l:indent
let l:leading_ws = s:Retab_Indent(l:indent)
if l:paragraph && (l:line == a:lastline || getline(l:line+1) =~ '\m^\s*$' || (&formatoptions =~ 'w' && l:line_string =~ '\m\S$'))
let l:line_replace = s:Align_String_Left(l:line_string)
else
let l:line_replace = s:Align_String_Justify(l:line_string,l:width)
endif
if &formatoptions =~ 'w' && l:line_string =~ '\m\s$'
let l:line_replace .= ' '
endif
call setline(l:line,l:leading_ws.l:line_replace)
let l:line += 1
" If fo=~w, does the paragraph end here? If yes,
" continue to next round and find a new first line.
if &formatoptions =~ 'w' && l:line_string =~ '\m\S$'
continue
endif
" If fo=~2 get the indent of the second line
if &formatoptions =~ '2'
let l:indent = indent(l:line)
let l:width = a:width - l:indent
let l:leading_ws = s:Retab_Indent(l:indent)
endif
" This loop will go through all the lines in the
" paragraph (or till the a:lastline) - starting from
" paragraph's second line.
while l:line <= a:lastline && getline(l:line) !~ '\m^\s*$'
let l:line_string = getline(l:line)
if l:paragraph && (l:line == a:lastline || getline(l:line+1) =~ '\m^\s*$' || (&formatoptions =~ 'w' && l:line_string =~ '\m\S$'))
let l:line_replace = s:Align_String_Left(l:line_string)
else
let l:line_replace = s:Align_String_Justify(l:line_string,l:width)
endif
if &formatoptions =~ 'w'
if l:line_string =~ '\m\s$'
call setline(l:line,l:leading_ws.l:line_replace.' ')
let l:line += 1
continue
else
call setline(l:line,l:leading_ws.l:line_replace)
let l:line += 1
" fo=~w and paragraph ends
" here so we break the loop.
" The next line is new first
" line.
break
endif
else
call setline(l:line,l:leading_ws.l:line_replace)
let l:line += 1
endif
endwhile
endwhile
endfunction
function! s:Align_Range_Center(width) "{{{1
let l:line_replace = s:Truncate_Spaces(getline('.'))
let l:line_replace = s:Add_Double_Spacing(l:line_replace)
if &formatoptions =~ 'w' && getline('.') =~ '\m\s$'
let l:line_replace .= ' '
endif
call setline(line('.'),l:line_replace)
execute '.center '.a:width
endfunction
function! s:Align_String_Left(string) "{{{1
let l:string_replace = s:Truncate_Spaces(a:string)
let l:string_replace = s:Add_Double_Spacing(l:string_replace)
return l:string_replace
endfunction
function! s:Align_String_Right(string, width) "{{{1
let l:string_replace = s:Truncate_Spaces(a:string)
let l:string_replace = s:Add_Double_Spacing(l:string_replace)
let l:string_width = s:String_Width(l:string_replace)
let l:more_spaces = a:width-l:string_width
return repeat(' ',l:more_spaces).l:string_replace
endfunction
function! s:Align_String_Justify(string, width) "{{{1
let l:string = s:Truncate_Spaces(a:string)
" If the parameter string is empty we can just return a line full of
" spaces. No need to go further.
if l:string =~ '\m^ *$'
return repeat(' ',a:width)
endif
if s:String_Width(s:Add_Double_Spacing(l:string)) >= a:width
" The original string is longer than width so we can just
" return the string. No need to go further.
return s:Add_Double_Spacing(l:string)
endif
let l:string_width = s:String_Width(l:string)
" This many extra spaces we need.
let l:more_spaces = a:width-l:string_width
" Convert the string to a list of words.
let l:word_list = split(l:string)
" This is the amount of spaces available in the original string (word
" count minus one).
let l:string_spaces = len(l:word_list)-1
" If there are no spaces there is only one word. We can just return
" the string with padded spaces. No need to go further.
if l:string_spaces == 0
return l:string.repeat(' ',l:more_spaces)
endif
" Ok, there are more than one word in the string so we get to do some
" real work...
" Make a list of which each item represent a space available in the
" string. The value means how many spaces there are. At the moment set
" every list item to one: [1, 1, 1, 1, ...]
let l:space_list = []
for l:item in range(l:string_spaces)
let l:space_list += [1]
endfor
" Repeat while there are no more need to add any spaces.
while l:more_spaces > 0
if l:more_spaces >= l:string_spaces
" More extra spaces are needed than there are spaces
" available in the string so we add one more space
" after every word (add 1 to items of space list).
for l:i in range(l:string_spaces)
let l:space_list[l:i] += 1
endfor
let l:more_spaces -= l:string_spaces
" And then another round... and a check if more spaces
" are needed.
else " l:more_spaces < l:string_spaces
" This list tells where .?! characters are.
let l:space_sentence_full = []
" This list tells where ,:; characters are.
let l:space_sentence_semi = []
" And this is for the rest of spaces.
let l:space_other = []
" Now, find those things:
for l:i in range(l:string_spaces)
if l:word_list[l:i] =~ '\m\S[.?!]$'
let l:space_sentence_full += [l:i]
elseif l:word_list[l:i] =~ '\m\S[,:;]$'
let l:space_sentence_semi += [l:i]
else
let l:space_other += [l:i]
endif
endfor
" First distribute spaces after .?!
if l:more_spaces >= len(l:space_sentence_full)
" If we need more extra spaces than there are
" .?! spaces, just add one after every item.
for l:i in l:space_sentence_full
let l:space_list[l:i] += 1
endfor
let l:more_spaces -= len(l:space_sentence_full)
if l:more_spaces == 0 | break | endif
else
" Distribute the rest of spaces evenly and
" break the loop. All the spaces have been
" added.
for l:i in s:Distributed_Selection(l:space_sentence_full,l:more_spaces)
let l:space_list[l:i] +=1
endfor
break
endif
" Then distribute spaces after ,:;
if l:more_spaces >= len(l:space_sentence_semi)
" If we need more extra spaces than there are
" ,:; spaces available, just add one after
" every item.
for l:i in l:space_sentence_semi
let l:space_list[l:i] += 1
endfor
let l:more_spaces -= len(l:space_sentence_semi)
if l:more_spaces == 0 | break | endif
else
" Distribute the rest of spaces evenly and
" break the loop. All the spaces have been
" added.
for l:i in s:Distributed_Selection(l:space_sentence_semi,l:more_spaces)
let l:space_list[l:i] +=1
endfor
break
endif
" Finally distribute spaces to other available
" positions and exit the loop.
for l:i in s:Distributed_Selection(l:space_other,l:more_spaces)
let l:space_list[l:i] +=1
endfor
break
endif
endwhile
" Now we now where all the extra spaces will go. We have to construct
" the string again.
let l:string = ''
for l:item in range(l:string_spaces)
let l:string .= l:word_list[l:item].repeat(' ',l:space_list[l:item])
endfor
" Add the last word to the end and return the string.
return l:string.l:word_list[-1]
endfunction
function! s:Truncate_Spaces(string) "{{{1
let l:string = substitute(a:string,'\v\s+',' ','g')
let l:string = substitute(l:string,'\m^\s*','','')
let l:string = substitute(l:string,'\m\s*$','','')
return l:string
endfunction
function! s:String_Width(string) "{{{1
" This counts the string width in characters. Combining diacritical
" marks do not count so the base character with all the combined
" diacritics is just one character (which is good for our purposes).
" Double-wide characters will not get double width so unfortunately
" they don't work in our algorithm.
return strlen(substitute(a:string,'\m.','x','g'))
endfunction
function! s:Add_Double_Spacing(string) "{{{1
if &joinspaces
return substitute(a:string,'\m\S[.?!] ','& ','g')
else
return a:string
endif
endfunction
function! s:Distributed_Selection(list, pick) "{{{1
" 'list' is a list-type variable [ item1, item2, ... ]
" 'pick' is a number how many of the list's items we want to choose
"
" This function returns a list which has 'pick' number of items from
" the original list. Items are chosen in distributed manner. For
" example, if 'pick' is 1 then the algorithm chooses an item near the
" center of the 'list'. If 'pick' is 2 then the first one is about 1/3
" from the beginning and the another one about 2/3 from the beginning.
" l:pick_list is a list of 0's and 1's and its length will be the
" same as original list's. Number 1 means that this list item will be
" picked and 0 means that the item will be dropped. Finally
" l:pick_list could look like this: [0, 1, 0, 1, 0]
" (i.e., two items evenly picked from a list of five items)
let l:pick_list = []
" First pick items evenly from the beginning of the list. This also
" actually constructs the list.
let l:div1 = len(a:list) / a:pick
let l:mod1 = len(a:list) % a:pick
for l:i in range(len(a:list)-l:mod1)
if !eval(l:i%l:div1)
let l:pick_list += [1]
else
let l:pick_list += [0]
endif
endfor
if l:mod1 > 0
" The division wasn't even so we get the remaining items and
" distribute them evenly again to the list.
let l:div2 = len(l:pick_list) / l:mod1
let l:mod2 = len(l:pick_list) % l:mod1
for l:i in range(len(l:pick_list)-l:mod2)
if !eval(l:i%l:div2)
call insert(l:pick_list,0,l:i)
endif
endfor
endif
" There may be very different number of zeros in the beginning and the
" end of the list. We count them.
let l:zeros_begin = 0
for l:i in l:pick_list
if l:i == 0
let l:zeros_begin += 1
else
break
endif
endfor
let l:zeros_end = 0
for l:i in reverse(copy(l:pick_list))
if l:i == 0
let l:zeros_end += 1
else
break
endif
endfor
" Then we remove them.
if l:zeros_end
" Remove "0" items from the end. We need to remove them first
" from the end because list items' index number will change
" when items are removed from the beginning. Then it would be
" more difficult to remove trailing zeros.
call remove(l:pick_list,len(l:pick_list)-l:zeros_end,-1)
endif
if l:zeros_begin
" Remove zero items from the beginning.
call remove(l:pick_list,0,l:zeros_begin-1)
endif
let l:zeros_both = l:zeros_begin + l:zeros_end
" Put even amount of zeros to beginning and end
for l:i in range(l:zeros_both/2)
call insert(l:pick_list,0,0)
endfor
for l:i in range((l:zeros_both/2)+(l:zeros_both%2))
call add(l:pick_list,0)
endfor
" Finally construct and return a new list which has only the items we
" have chosen.
let l:new_list = []
for l:i in range(len(l:pick_list))
if l:pick_list[l:i] == 1
let l:new_list += [a:list[l:i]]
endif
endfor
return l:new_list
endfunction
function! s:Retab_Indent(column) "{{{1
" column = the left indent column starting from 0 Function returns
" a string of whitespaces, a mixture of tabs and spaces depending on
" the 'expandtab' and 'tabstop' options.
if &expandtab
" Only spaces
return repeat(' ',a:column)
else
" Tabs and spaces
let l:tabs = a:column / &tabstop
let l:spaces = a:column % &tabstop
return repeat("\<Tab>",l:tabs).repeat(' ',l:spaces)
endif
endfunction
function! s:Reformat_Range(...) range "{{{1
if a:0 == 2
let l:first = a:1
let l:last = a:2
else
let l:first = a:firstline
let l:last = a:lastline
endif
let l:autoindent = &autoindent
setlocal autoindent
execute l:first
normal! 0
execute 'normal! V'.l:last.'G$gw'
let &l:autoindent = l:autoindent
" The formatting may change the last line of the range so we return
" it.
return line("'>")
endfunction
function! textformat#Visual_Align_Left() range "{{{1
execute a:firstline.','.a:lastline.'call s:Align_Range_Left()'
call s:Reformat_Range(a:firstline,a:lastline)
endfunction
function! textformat#Visual_Align_Right() range "{{{1
let l:width = &textwidth
if l:width == 0 | let l:width = s:default_width | endif
execute a:firstline.','.a:lastline.'call s:Align_Range_Right('.l:width.')'
normal! '>$
endfunction
function! textformat#Visual_Align_Justify() range "{{{1
let l:width = &textwidth
if l:width == 0 | let l:width = s:default_width | endif
execute a:firstline.','.a:lastline.'call s:Align_Range_Left()'
let l:last = s:Reformat_Range(a:firstline,a:lastline)
let l:pos = getpos('.')
execute a:firstline.','.l:last.'call s:Align_Range_Justify('.l:width.',1)'
call setpos('.',l:pos)
endfunction
function! textformat#Visual_Align_Center() range "{{{1
let l:width = &textwidth
if l:width == 0 | let l:width = s:default_width | endif
execute a:firstline.','.a:lastline.'call s:Align_Range_Center('.l:width.')'
normal! '>$
endfunction
function! textformat#Quick_Align_Left() "{{{1
let l:autoindent = &autoindent
setlocal autoindent
let l:pos = getpos('.')
silent normal! vip:call s:Align_Range_Left()
call setpos('.',l:pos)
silent normal! gwip
let &l:autoindent = l:autoindent
endfunction
function! textformat#Quick_Align_Right() "{{{1
let l:width = &textwidth
if l:width == 0 | let l:width = s:default_width | endif
let l:pos = getpos('.')
silent normal! vip:call s:Align_Range_Right(l:width)
call setpos('.',l:pos)
endfunction
function! textformat#Quick_Align_Justify() "{{{1
let l:width = &textwidth
if l:width == 0 | let l:width = s:default_width | endif
let l:autoindent = &autoindent
setlocal autoindent
let l:pos = getpos('.')
silent normal! vip:call s:Align_Range_Left()
call setpos('.',l:pos)
silent normal! gwip
let l:pos = getpos('.')
silent normal! vip:call s:Align_Range_Justify(l:width,1)
call setpos('.',l:pos)
let &l:autoindent = l:autoindent
endfunction
function! textformat#Quick_Align_Center() "{{{1
let l:width = &textwidth
if l:width == 0 | let l:width = s:default_width | endif
let l:pos = getpos('.')
silent normal! vip:call s:Align_Range_Center(l:width)
call setpos('.',l:pos)
endfunction
function! textformat#Align_Command(align, ...) range "{{{1
" For left align the optional parameter a:1 is [indent]. For others
" it's [width].
let l:pos = getpos('.')
if a:align ==? 'left'
if a:0 && a:1 >= 0
execute a:firstline.','.a:lastline.'call s:Align_Range_Left('.a:1.')'
else
execute a:firstline.','.a:lastline.'call s:Align_Range_Left()'
endif
else
if a:0 && a:1 > 0
let l:width = a:1
elseif &textwidth
let l:width = &textwidth
else
let l:width = s:default_width
endif
if a:align ==? 'right'
execute a:firstline.','.a:lastline.'call s:Align_Range_Right('.l:width.')'
elseif a:align ==? 'justify'
execute a:firstline.','.a:lastline.'call s:Align_Range_Justify('.l:width.')'
elseif a:align ==? 'center'
execute a:firstline.','.a:lastline.'call s:Align_Range_Center('.l:width.')'
endif
endif
call setpos('.',l:pos)
endfunction
"{{{1 The ending stuff
let &cpo = s:save_cpo
" vim600: fdm=marker

View File

@ -0,0 +1,10 @@
:AlignCenter textformat.txt /*:AlignCenter*
:AlignJustify textformat.txt /*:AlignJustify*
:AlignLeft textformat.txt /*:AlignLeft*
:AlignRight textformat.txt /*:AlignRight*
textformat-commands textformat.txt /*textformat-commands*
textformat-config textformat.txt /*textformat-config*
textformat-history textformat.txt /*textformat-history*
textformat-keymap textformat.txt /*textformat-keymap*
textformat-start textformat.txt /*textformat-start*
textformat.txt textformat.txt /*textformat.txt*

View File

@ -0,0 +1,301 @@
*textformat.txt* Vim Text Formatter (version 2.1) 2008-09-13
Description This plugin provides commands and key mappings to quickly
align and format text. Text can be easily reformatted and
aligned to either left or right margin or justified to both
margins or centered. The text formatting commands provided by
this plugin are a bit more automatic and more intelligent than
those integrated to Vim. Together they make more powerful
command set for formatting text.
Author Teemu Likonen <tlikonen@iki.fi>
Contents
1. Quick start |textformat-start|
2. Commands |textformat-commands|
3. Default key mappings |textformat-keymap|
4. Configuration |textformat-config|
5. Version history |textformat-history|
==============================================================================
1. Quick start *textformat-start*
The impatient are always with us so below is a short info on (probably) the
most important tools provided by this plugin. See the following sections of
this manual for more detailed instructions.
<Leader>al Left-align and reformat
<Leader>ar Right-align
<Leader>aj Left-right justify and reformat
<Leader>ac Center lines
In normal mode the commands operate on current paragraph; in visual mode they
operate on the selected lines. By default, <Leader> is the backslash key, so
the mappings are actually \al, \ar, \aj and \ac, by default. If you have
changed the g:mapleader variable in your .vimrc file <Leader> may be something
else.
==============================================================================
2. Commands *textformat-commands*
Let's start with the basic components of this plugin. These are the ex
commands. You probably don't need these very often but they can be handy if
you want to have text formatting and aligning as a part of a macro or function
or something. The "daily tools" are explained later.
:[range]AlignLeft [indent] *:AlignLeft*
Align to left all the lines in [range] (default is
current line) and truncate all extra whitespace
characters. That is, if there are more than one space
between words they are reduced to just one. If
'joinspaces' is set then two spaces are added after
every sentence ending with character ".", "?" or "!".
If optional numeric argument [indent] is given then
that is used as the left margin. If [indent] is not
given the indent of the first line in the [range] (and
the first line of each paragraph within the [range])
is used to define indent for the rest of the lines in
the paragraph. There is one exception: if
'formatoptions' contains "2" then the second line
defines the indent for the rest of the lines in the
paragraph.
Note: This is very similar to |:left| command except
that this also truncates whitespaces and that without
[indent] each paragraph's indent is detected and used.
Note: There is a possible unexpected behaviour: If
command is run without [range] (i.e., it's just the
current line) and [indent] is not given then this
command just "aligns" to the current indent position
and truncates whitespaces. You might see nothing
happening if there weren't any extra whitespaces. Use
[indent] (or |:left| command) to align to desired
column.
:[range]AlignRight [width] *:AlignRight*
Align to right all the lines in [range] (default is
current line) and truncate all extra whitespace
characters (honor 'joinspaces', as in :AlignLeft).
[width] is used as the right margin. If [width] is not
given the value of 'textwidth' option is used instead.
If 'textwidth' is zero then the value of 80 is used.
Note: This is very similar to |:right| command except
that this also truncates whitespaces.
:[range]AlignJustify [width] *:AlignJustify*
Left-right justify lines in [range] (default is
current line). This means adjusting spaces between
words so that the lines fit. If 'joinspaces' is set
then at least two spaces are printed after every
sentence ending with a ".", "?" or "!". The first line
in [range] (and the first line in each paragraph
within the [range]) defines the indent for the rest of
the lines in the paragraph, except if 'formatoptions'
contains "2" then it's the second line.
Numeric argument [width] is used as the right margin.
If [width] is not given the value of 'textwidth' is
used instead. If 'textwidth' is zero then the value of
80 is used.
Also see the Discussion below.
:[range]AlignCenter [width] *:AlignCenter*
Center lines in [range] (default is current line)
between the first column and [width]. All extra
whitespace characters are truncated (but honor
'joinspaces', just like in :AlignLeft). If [width] is
not given the value of 'textwidth' option is used
instead. If 'textwidth' is zero the value of 80 is
used.
Note: This is very similar to |:center| except that
this also truncates whitespaces.
Discussion ~
All the previous ex commands are rather "stupid" and operate on single lines
only. They do not wrap lines nor do other kind of formatting. If [width] (or
'textwidth') is too narrow for the line then some characters will go beyond
the right margin. This is similar to Vim's own |:left|, |:right| and |:center|
commands. More sophisticated formatting tools are provided as key mappings
(see below).
Usually when paragraphs are justified the last line of each paragraph is
aligned to left. However, :AlignJustify command does not do this. The purpose
of this command is to do exactly what was asked for: left-right justify
a range of lines. More sophisticated justify tools is <Leader>aj which
reformats the paragraph (like |gw|), justifies lines and aligns each
paragraph's last line to left.
All the commands truncate extra whitespaces which makes them work well
together. This is particularly because the left-right justify needs to add
extra spaces to make lines fill the text area. If you later want to reformat
such previously justified paragraph and align it to left, for example, it's
convenient that the tool automatically handles this and removes extra spaces.
If you want to align text without truncating whitespaces use Vim's own align
commands: |:left|, |:right| and |:center|.
==============================================================================
3. Default key mappings *textformat-keymap*
By default this plugin provides a couple of key mappings for convenient text
formatting. If the mappings have already been defined by user (or are taken by
other plugins) then some of the following mappings may not be automatically
available. See the next section of this manual for information on how to
change the default mappings.
There are key mappings available for normal mode and visual mode. As usual,
<Leader> is the backslash key by default but it can be changed with
g:mapleader variable. Consult the Vim manual for more information on <Leader>.
Normal mode (current paragraph) ~
<Leader>al Left-align the current "inner paragraph" (see |ip|)
and reformat it according to 'textwidth'.
<Leader>ar Right-align the current "inner paragraph" (see |ip|)
to margin at 'textwidth'. This does not reformat the
paragraph because with right-aligned text user usually
wants to decide exactly what goes to what line.
<Leader>aj Left-right justify the current "inner paragraph" (see
|ip|). Technically each line's whitespaces are first
truncated, then the text is reformatted according to
'textwidth' and finally lines are justified. The last
line (of each text paragraph) is aligned to left.
<Leader>ac Center lines of current "inner paragraph" (see |ip|)
between the first column and 'textwidth'. This does
not reformat the paragraph because with centered text
user usually wants to decide exactly what goes to what
line.
Visual mode (range of lines) ~
{Visual}<Leader>al Left-align and reformat {Visual} lines so that they
fill 'textwidth'.
{Visual}<Leader>ar Right-align {Visual} lines.
{Visual}<Leader>aj Left-right justify {Visual} lines. First truncate all
extra whitespace characters, then reformat lines so
that they fill 'textwidth' and finally left-right
justify. The last line of each paragraph as well as
the last line in {Visual} range is aligned to left.
{Visual}<Leader>ac Center {Visual} lines.
Both normal mode and visual mode commands truncate extra whitespace
characters. If 'joinspaces' is set then an extra space is added after every
sentence ending with a ".", "?" or "!". The first line in each paragraph
inside the range defines the indent for the rest of the lines in the
paragraph, except if 'formatoptions' contains "2" then it's the second line.
Paragraph definitions ~
The normal mode commands operate on the concept of "inner paragraph" (see
|ip|). The effect is almost the same as selecting current paragraph with Vim's
"vip" command and then executing the equivalent visual mode command. Such
inner paragraph may contain several text paragraphs if 'formatoptions'
contains "w". Each of them is reformatted separately with <Leader>al and
<Leader>aj commands.
New paragraph always begins after a blank line. If 'formatoptions' contains
"w" then new paragraph also begins after a line which ends with
a non-whitespace character. That is, with "w" in 'formatoptions' every line
which ends with a non-whitespace also ends a paragraph. In left-right justify
(<Leader>aj) such line is aligned to left. You need to ensure that there is
a trailing whitespace in every consecutive line which belongs to same
paragraph (the whitespace is preserved after formatting). If 'formatoptions'
does not contain "w" then all consecutive non-blank lines belong to same
paragraph.
==============================================================================
4. Configuration *textformat-config*
The key mappings can be configured freely by user. This plugin uses the
default ones only if they are free and not used for other purposes. Here's an
example of lines you could put to your .vimrc file:
>
nmap <F5> <Plug>Quick_Align_Paragraph_Left
nmap <F6> <Plug>Quick_Align_Paragraph_Right
nmap <F7> <Plug>Quick_Align_Paragraph_Justify
nmap <F8> <Plug>Quick_Align_Paragraph_Center
vmap <F5> <Plug>Align_Range_Left
vmap <F6> <Plug>Align_Range_Right
vmap <F7> <Plug>Align_Range_Justify
vmap <F8> <Plug>Align_Range_Center
That is, |:nmap| command defines mappings for normal mode and |:vmap| for
visual mode. Function keys from <F5> to <F8> are used in this example. The
rest of the line is a code word for Vim and this plugin. They must be written
exactly as shown in the example. I think the code words are pretty much
self-descriptive.
Don't use |:nnoremap| and |:vnoremap| commands here; they don't work because
the right-hand side (<Plug>...) must be remappable. See Vim's manual for more
information about the key map commands.
Most part of this plugin is loaded into memory when the text-formatting
commands or key maps are used for the first time. Only the very minimum is
automatically loaded when Vim is started. If you want to completely avoid
loading this plugin put the following line to your .vimrc file:
>
let g:loaded_textformat = 1
Happy formatting!
==============================================================================
5. Version history *textformat-history*
v2.1 2008-09-13
- Minor internal cleanup.
v2.0 2008-08-10
- \al and \aj now reformat text also in visual mode.
- \al and \aj honor "w" in 'formatoptions' and detect paragraph
boundaries accordingly.
- :AlignLeft, :AlignJustify, \al and \aj recognize several
paragraphs within the range and detect indent for each
paragraph separately.
- Add logic to load the plugin script only once.
v1.1 2008-08-04
- Keep cursor position more accurately when formatting
a paragraph with \al and \aj.
- When 'joinspaces' is set insert two spaces after .?!
punctuation with left-right justify. This is now similar to
other commands.
v1.0 2008-08-03
- All the commands now follow user's 'expandtab' setting and
print leading whitespaces accordingly. Now this works just
like :left, :right and :center commands.
- The left-aligned last line in justified paragraph did not
honor 'joinspaces'. Fixed.
v0.9 2008-08-01
- Initial upload to http://www.vim.org .
==============================================================================
vim: ft=help tw=78 ts=8 et norl fo+=2aw

View File

@ -0,0 +1,89 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=1218
Grab the latest dev version from github: https://github.com/scrooloose/nerdcommenter.
The following key mappings are provided by default (there is also a menu
provided that contains menu items corresponding to all the below mappings):
Most of the following mappings are for normal/visual mode only. The
|NERDComInsertComment| mapping is for insert mode only.
,cc |NERDComComment|
Comments out the current line or text selected in visual mode.
,cn |NERDComNestedComment|
Same as |NERDComComment| but forces nesting.
,c<space> |NERDComToggleComment|
Toggles the comment state of the selected line(s). If the topmost selected
line is commented, all selected lines are uncommented and vice versa.
,cm |NERDComMinimalComment|
Comments the given lines using only one set of multipart delimiters if
possible.
,ci |NERDComInvertComment|
Toggles the comment state of the selected line(s) individually. Each selected
line that is commented is uncommented and vice versa.
,cs |NERDComSexyComment|
Comments out the selected lines ``sexily''
,cy |NERDComYankComment|
Same as |NERDComComment| except that the commented line(s) are yanked
before commenting.
,c$ |NERDComEOLComment|
Comments the current line from the cursor to the end of line.
,cA |NERDComAppendComment|
Adds comment delimiters to the end of line and goes into insert mode between
them.
,cI |NERDComPrependComment|
Adds comment delimiters to the start of line and goes into insert mode between
them.
|NERDComInsertComment|
Adds comment delimiters at the current cursor position and inserts between.
Disabled by default.
,ca |NERDComAltDelim|
Switches to the alternative set of delimiters.
,cl OR ,cr OR ,cb |NERDComAlignedComment|
Same as |NERDComComment| except that the delimiters are aligned down the
left side (,cl), the right side (,cr) or both sides
(,cb).
,cu |NERDComUncommentLine|
Uncomments the selected line(s).
Filetypes that can be commented by this plugin:
abaqus abc acedb ada ahdl amiga aml ampl ant apache apachestyle asm68k asm asn
aspvbs atlas autohotkey autoit automake ave awk basic b bc bdf bib bindzone bst
btm caos catalog c cfg cg ch changelog cl clean clipper cmake conf config
context cpp crontab cs csc csp css cterm cupl csv cvs dcl debchangelog
debcontrol debsources def diff django docbk dns dosbatch dosini dot dracula dsl
dtd dtml dylan ecd eiffel elf elmfilt erlang eruby eterm expect exports
fetchmail fgl focexec form fortran foxpro fstab fvwm fx gdb gdmo geek
gentoo-package-keywords' gentoo-package-mask' gentoo-package-use' gnuplot gtkrc
haskell hb h help hercules hog html htmldjango htmlos ia64 icon idlang idl
indent inform inittab ishd iss ist jam java javascript jess jgraph jproperties
jproperties jsp kconfig kix kscript lace lex lftp lifelines lilo lisp lite
lotos lout lprolog lscript lss lua lynx m4 mail make maple masm master matlab
mel mf mib mma model moduala. modula2 modula3 monk mush muttrc named nasm
nastran natural ncf netdict netrw nqc nroff nsis ocaml occam omlet omnimark
openroad opl ora otl ox pascal passwd pcap pccts perl pfmain php phtml pic pike
pilrc pine plaintex plm plsql po postscr pov povini ppd ppwiz procmail progress
prolog psf ptcap python python qf radiance ratpoison r rc readline rebol
registry remind rexx robots rpl rtf ruby sa samba sas sather scheme scilab
screen scsh sdl sed selectbuf sgml sgmldecl sgmllnx sicad simula sinda skill
slang sl slrnrc sm smarty smil smith sml snnsnet snnspat snnsres snobol4 spec
specman spice sql sqlforms sqlj sqr squid st stp strace svn systemverilog tads
taglist tags tak tasm tcl terminfo tex text plaintex texinfo texmf tf tidy tli
trasys tsalt tsscl tssgm uc uil vb verilog verilog_systemverilog vgrindefs vhdl
vim viminfo virata vo_base vrml vsejcl webmacro wget winbatch wml [^w]*sh
wvdial xdefaults xf86conf xhtml xkb xmath xml xmodmap xpm2 xpm xslt yacc yaml
z8a

View File

@ -0,0 +1,988 @@
*NERD_commenter.txt* Plugin for commenting code
NERD COMMENTER REFERENCE MANUAL~
==============================================================================
CONTENTS *NERDCommenterContents*
1.Intro...................................|NERDCommenter|
2.Installation............................|NERDComInstallation|
3.Functionality provided..................|NERDComFunctionality|
3.1 Functionality Summary.............|NERDComFunctionalitySummary|
3.2 Functionality Details.............|NERDComFunctionalityDetails|
3.2.1 Comment map.................|NERDComComment|
3.2.2 Nested comment map..........|NERDComNestedComment|
3.2.3 Toggle comment map..........|NERDComToggleComment|
3.2.4 Minimal comment map.........|NERDComMinimalComment|
3.2.5 Invert comment map..........|NERDComInvertComment|
3.2.6 Sexy comment map............|NERDComSexyComment|
3.2.7 Yank comment map............|NERDComYankComment|
3.2.8 Comment to EOL map..........|NERDComEOLComment|
3.2.9 Append com to line map......|NERDComAppendComment|
3.2.10 Insert comment map.........|NERDComInsertComment|
3.2.11 Use alternate delims map...|NERDComAltDelim|
3.2.12 Comment aligned maps.......|NERDComAlignedComment|
3.2.13 Uncomment line map.........|NERDComUncommentLine|
3.4 Sexy Comments.....................|NERDComSexyComments|
3.5 The NERDComment function..........|NERDComNERDComment|
4.Options.................................|NERDComOptions|
4.1 Options summary...................|NERDComOptionsSummary|
4.2 Options details...................|NERDComOptionsDetails|
4.3 Default delimiter Options.........|NERDComDefaultDelims|
5. Customising key mappings...............|NERDComMappings|
6. Issues with the script.................|NERDComIssues|
6.1 Delimiter detection heuristics....|NERDComHeuristics|
6.2 Nesting issues....................|NERDComNesting|
7.About.. ............................|NERDComAbout|
8.Changelog...............................|NERDComChangelog|
9.Credits.................................|NERDComCredits|
10.License................................|NERDComLicense|
==============================================================================
1. Intro *NERDCommenter*
The NERD commenter provides many different commenting operations and styles
which are invoked via key mappings and a menu. These operations are available
for most filetypes.
There are also options that allow to tweak the commenting engine to your
taste.
==============================================================================
2. Installation *NERDComInstallation*
The NERD Commenter requires Vim 7 or higher.
Extract the plugin files in your ~/.vim (*nix) or ~/vimfiles (Windows). You
should have 2 files: >
plugin/NERD_commenter.vim
doc/NERD_commenter.txt
<
Next, to finish installing the help file run: >
:helptags ~/.vim/doc
<
See |add-local-help| for more details.
Make sure that you have filetype plugins enabled, as the script makes use of
|'commentstring'| where possible (which is usually set in a filetype plugin).
See |filetype-plugin-on| for details, but basically, stick this in your vimrc >
filetype plugin on
<
==============================================================================
3. Functionality provided *NERDComFunctionality*
------------------------------------------------------------------------------
3.1 Functionality summary *NERDComFunctionalitySummary*
The following key mappings are provided by default (there is also a menu
with items corresponding to all the mappings below):
[count]<leader>cc |NERDComComment|
Comment out the current line or text selected in visual mode.
[count]<leader>cn |NERDComNestedComment|
Same as <leader>cc but forces nesting.
[count]<leader>c<space> |NERDComToggleComment|
Toggles the comment state of the selected line(s). If the topmost selected
line is commented, all selected lines are uncommented and vice versa.
[count]<leader>cm |NERDComMinimalComment|
Comments the given lines using only one set of multipart delimiters.
[count]<leader>ci |NERDComInvertComment|
Toggles the comment state of the selected line(s) individually.
[count]<leader>cs |NERDComSexyComment|
Comments out the selected lines ``sexily''
[count]<leader>cy |NERDComYankComment|
Same as <leader>cc except that the commented line(s) are yanked first.
<leader>c$ |NERDComEOLComment|
Comments the current line from the cursor to the end of line.
<leader>cA |NERDComAppendComment|
Adds comment delimiters to the end of line and goes into insert mode between
them.
|NERDComInsertComment|
Adds comment delimiters at the current cursor position and inserts between.
Disabled by default.
<leader>ca |NERDComAltDelim|
Switches to the alternative set of delimiters.
[count]<leader>cl
[count]<leader>cb |NERDComAlignedComment|
Same as |NERDComComment| except that the delimiters are aligned down the
left side (<leader>cl) or both sides (<leader>cb).
[count]<leader>cu |NERDComUncommentLine|
Uncomments the selected line(s).
------------------------------------------------------------------------------
3.2 Functionality details *NERDComFunctionalityDetails*
------------------------------------------------------------------------------
3.2.1 Comment map *NERDComComment*
Default mapping: [count]<leader>cc
Mapped to: <plug>NERDCommenterComment
Applicable modes: normal visual visual-line visual-block.
Comments out the current line. If multiple lines are selected in visual-line
mode, they are all commented out. If some text is selected in visual or
visual-block mode then the script will try to comment out the exact text that
is selected using multi-part delimiters if they are available.
If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
------------------------------------------------------------------------------
3.2.2 Nested comment map *NERDComNestedComment*
Default mapping: [count]<leader>cn
Mapped to: <plug>NERDCommenterNest
Applicable modes: normal visual visual-line visual-block.
Performs nested commenting. Works the same as <leader>cc except that if a line
is already commented then it will be commented again.
If |'NERDUsePlaceHolders'| is set then the previous comment delimiters will
be replaced by place-holder delimiters if needed. Otherwise the nested
comment will only be added if the current commenting delimiters have no right
delimiter (to avoid syntax errors)
If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
Related options:
|'NERDDefaultNesting'|
------------------------------------------------------------------------------
3.2.3 Toggle comment map *NERDComToggleComment*
Default mapping: [count]<leader>c<space>
Mapped to: <plug>NERDCommenterToggle
Applicable modes: normal visual-line.
Toggles commenting of the lines selected. The behaviour of this mapping
depends on whether the first line selected is commented or not. If so, all
selected lines are uncommented and vice versa.
With this mapping, a line is only considered to be commented if it starts with
a left delimiter.
If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
------------------------------------------------------------------------------
3.2.4 Minimal comment map *NERDComMinimalComment*
Default mapping: [count]<leader>cm
Mapped to: <plug>NERDCommenterMinimal
Applicable modes: normal visual-line.
Comments the selected lines using one set of multipart delimiters if possible.
For example: if you are programming in c and you select 5 lines and press
<leader>cm then a '/*' will be placed at the start of the top line and a '*/'
will be placed at the end of the last line.
Sets of multipart comment delimiters that are between the top and bottom
selected lines are replaced with place holders (see |'NERDLPlace'|) if
|'NERDUsePlaceHolders'| is set for the current filetype. If it is not, then
the comment will be aborted if place holders are required to prevent illegal
syntax.
If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
------------------------------------------------------------------------------
3.2.5 Invert comment map *NERDComInvertComment*
Default mapping: <leader>ci
Mapped to: <plug>NERDCommenterInvert
Applicable modes: normal visual-line.
Inverts the commented state of each selected line. If the a selected line is
commented then it is uncommented and vice versa. Each line is examined and
commented/uncommented individually.
With this mapping, a line is only considered to be commented if it starts with
a left delimiter.
If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
------------------------------------------------------------------------------
3.2.6 Sexy comment map *NERDComSexyComment*
Default mapping: [count]<leader>cs
Mapped to: <plug>NERDCommenterSexy
Applicable modes: normal, visual-line.
Comments the selected line(s) ``sexily''... see |NERDComSexyComments| for
a description of what sexy comments are. Can only be done on filetypes for
which there is at least one set of multipart comment delimiters specified.
Sexy comments cannot be nested and lines inside a sexy comment cannot be
commented again.
If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
Related options:
|'NERDCompactSexyComs'|
------------------------------------------------------------------------------
3.2.7 Yank comment map *NERDComYankComment*
Default mapping: [count]<leader>cy
Mapped to: <plug>NERDCommenterYank
Applicable modes: normal visual visual-line visual-block.
Same as <leader>cc except that it yanks the line(s) that are commented first.
------------------------------------------------------------------------------
3.2.8 Comment to EOL map *NERDComEOLComment*
Default mapping: <leader>c$
Mapped to: <plug>NERDCommenterToEOL
Applicable modes: normal.
Comments the current line from the current cursor position up to the end of
the line.
------------------------------------------------------------------------------
3.2.9 Append com to line map *NERDComAppendComment*
Default mapping: <leader>cA
Mapped to: <plug>NERDCommenterAppend
Applicable modes: normal.
Appends comment delimiters to the end of the current line and goes
to insert mode between the new delimiters.
------------------------------------------------------------------------------
3.2.10 Insert comment map *NERDComInsertComment*
Default mapping: disabled by default.
Map it to: <plug>NERDCommenterInInsert
Applicable modes: insert.
Adds comment delimiters at the current cursor position and inserts
between them.
NOTE: prior to version 2.1.17 this was mapped to ctrl-c. To restore this
mapping add >
let NERDComInsertMap='<c-c>'
<
to your vimrc.
------------------------------------------------------------------------------
3.2.11 Use alternate delims map *NERDComAltDelim*
Default mapping: <leader>ca
Mapped to: <plug>NERDCommenterAltDelims
Applicable modes: normal.
Changes to the alternative commenting style if one is available. For example,
if the user is editing a c++ file using // comments and they hit <leader>ca
then they will be switched over to /**/ comments.
See also |NERDComDefaultDelims|
------------------------------------------------------------------------------
3.2.12 Comment aligned maps *NERDComAlignedComment*
Default mappings: [count]<leader>cl [count]<leader>cb
Mapped to: <plug>NERDCommenterAlignLeft
<plug>NERDCommenterAlignBoth
Applicable modes: normal visual-line.
Same as <leader>cc except that the comment delimiters are aligned on the left
side or both sides respectively. These comments are always nested if the
line(s) are already commented.
If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
------------------------------------------------------------------------------
3.2.13 Uncomment line map *NERDComUncommentLine*
Default mapping: [count]<leader>cu
Mapped to: <plug>NERDCommenterUncomment
Applicable modes: normal visual visual-line visual-block.
Uncomments the current line. If multiple lines are selected in
visual mode then they are all uncommented.
When uncommenting, if the line contains multiple sets of delimiters then the
``outtermost'' pair of delimiters will be removed.
The script uses a set of heurisics to distinguish ``real'' delimiters from
``fake'' ones when uncommenting. See |NERDComIssues| for details.
If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
Related options:
|'NERDRemoveAltComs'|
|'NERDRemoveExtraSpaces'|
------------------------------------------------------------------------------
3.3 Sexy Comments *NERDComSexyComments*
These are comments that use one set of multipart comment delimiters as well as
one other marker symbol. For example: >
/*
* This is a c style sexy comment
* So there!
*/
/* This is a c style sexy comment
* So there!
* But this one is ``compact'' style */
<
Here the multipart delimiters are /* and */ and the marker is *.
------------------------------------------------------------------------------
3.4 The NERDComment function *NERDComNERDComment*
All of the NERD commenter mappings and menu items invoke a single function
which delegates the commenting work to other functions. This function is
public and has the prototype: >
function! NERDComment(isVisual, type)
<
The arguments to this function are simple:
- isVisual: if you wish to do any kind of visual comment then set this to
1 and the function will use the '< and '> marks to find the comment
boundries. If set to 0 then the function will operate on the current
line.
- type: is used to specify what type of commenting operation is to be
performed, and it can be one of the following: "sexy", "invert",
"minimal", "toggle", "alignLeft", "alignBoth", "norm", "nested",
"toEOL", "append", "insert", "uncomment", "yank"
For example, if you typed >
:call NERDComment(1, 'sexy')
<
then the script would do a sexy comment on the last visual selection.
==============================================================================
4. Options *NERDComOptions*
------------------------------------------------------------------------------
4.1 Options summary *NERDComOptionsSummary*
|'loaded_nerd_comments'| Turns off the script.
|'NERDAllowAnyVisualDelims'| Allows multipart alternative delims to
be used when commenting in
visual/visual-block mode.
|'NERDBlockComIgnoreEmpty'| Forces right delims to be placed when
doing visual-block comments.
|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments.
|'NERDCreateDefaultMappings'| Turn the default mappings on/off.
|'NERDDefaultNesting'| Tells the script to use nested comments
by default.
|'NERDMenuMode'| Specifies how the NERD commenter menu
will appear (if at all).
|'NERDLPlace'| Specifies what to use as the left
delimiter placeholder when nesting
comments.
|'NERDUsePlaceHolders'| Specifies which filetypes may use
placeholders when nesting comments.
|'NERDRemoveAltComs'| Tells the script whether to remove
alternative comment delimiters when
uncommenting.
|'NERDRemoveExtraSpaces'| Tells the script to always remove the
extra spaces when uncommenting
(regardless of whether NERDSpaceDelims
is set)
|'NERDRPlace'| Specifies what to use as the right
delimiter placeholder when nesting
comments.
|'NERDSpaceDelims'| Specifies whether to add extra spaces
around delimiters when commenting, and
whether to remove them when
uncommenting.
|'NERDCompactSexyComs'| Specifies whether to use the compact
style sexy comments.
------------------------------------------------------------------------------
4.3 Options details *NERDComOptionsDetails*
To enable any of the below options you should put the given line in your
~/.vimrc
*'loaded_nerd_comments'*
If this script is driving you insane you can turn it off by setting this
option >
let loaded_nerd_comments=1
<
------------------------------------------------------------------------------
*'NERDAllowAnyVisualDelims'*
Values: 0 or 1.
Default: 1.
If set to 1 then, when doing a visual or visual-block comment (but not a
visual-line comment), the script will choose the right delimiters to use for
the comment. This means either using the current delimiters if they are
multipart or using the alternative delimiters if THEY are multipart. For
example if we are editing the following java code: >
float foo = 1221;
float bar = 324;
System.out.println(foo * bar);
<
If we are using // comments and select the "foo" and "bar" in visual-block
mode, as shown left below (where '|'s are used to represent the visual-block
boundary), and comment it then the script will use the alternative delims as
shown on the right: >
float |foo| = 1221; float /*foo*/ = 1221;
float |bar| = 324; float /*bar*/ = 324;
System.out.println(foo * bar); System.out.println(foo * bar);
<
------------------------------------------------------------------------------
*'NERDBlockComIgnoreEmpty'*
Values: 0 or 1.
Default: 1.
This option affects visual-block mode commenting. If this option is turned
on, lines that begin outside the right boundary of the selection block will be
ignored.
For example, if you are commenting this chunk of c code in visual-block mode
(where the '|'s are used to represent the visual-block boundary) >
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
|int| main(){
| | printf("SUCK THIS\n");
| | while(1){
| | fork();
| | }
|} |
<
If NERDBlockComIgnoreEmpty=0 then this code will become: >
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
/*int*/ main(){
/* */ printf("SUCK THIS\n");
/* */ while(1){
/* */ fork();
/* */ }
/*} */
<
Otherwise, the code block would become: >
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
/*int*/ main(){
printf("SUCK THIS\n");
while(1){
fork();
}
/*} */
<
------------------------------------------------------------------------------
*'NERDCommentWholeLinesInVMode'*
Values: 0, 1 or 2.
Default: 0.
By default the script tries to comment out exactly what is selected in visual
mode (v). For example if you select and comment the following c code (using |
to represent the visual boundary): >
in|t foo = 3;
int bar =| 9;
int baz = foo + bar;
<
This will result in: >
in/*t foo = 3;*/
/*int bar =*/ 9;
int baz = foo + bar;
<
But some people prefer it if the whole lines are commented like: >
/*int foo = 3;*/
/*int bar = 9;*/
int baz = foo + bar;
<
If you prefer the second option then stick this line in your vimrc: >
let NERDCommentWholeLinesInVMode=1
<
If the filetype you are editing only has no multipart delimiters (for example
a shell script) and you hadnt set this option then the above would become >
in#t foo = 3;
#int bar = 9;
<
(where # is the comment delimiter) as this is the closest the script can
come to commenting out exactly what was selected. If you prefer for whole
lines to be commented out when there is no multipart delimiters but the EXACT
text that was selected to be commented out if there IS multipart delimiters
then stick the following line in your vimrc: >
let NERDCommentWholeLinesInVMode=2
<
Note that this option does not affect the behaviour of commenting in
|visual-block| mode.
------------------------------------------------------------------------------
*'NERDCreateDefaultMappings'*
Values: 0 or 1.
Default: 1.
If set to 0, none of the default mappings will be created.
See also |NERDComMappings|.
------------------------------------------------------------------------------
*'NERDRemoveAltComs'*
Values: 0 or 1.
Default: 1.
When uncommenting a line (for a filetype with an alternative commenting style)
this option tells the script whether to look for, and remove, comment
delimiters of the alternative style.
For example, if you are editing a c++ file using // style comments and you go
<leader>cu on this line: >
/* This is a c++ comment baby! */
<
It will not be uncommented if the NERDRemoveAltComs is set to 0.
------------------------------------------------------------------------------
*'NERDRemoveExtraSpaces'*
Values: 0 or 1.
Default: 1.
By default, the NERD commenter will remove spaces around comment delimiters if
either:
1. |'NERDSpaceDelims'| is set to 1.
2. NERDRemoveExtraSpaces is set to 1.
This means that if we have the following lines in a c code file: >
/* int foo = 5; */
/* int bar = 10; */
int baz = foo + bar
<
If either of the above conditions hold then if these lines are uncommented
they will become: >
int foo = 5;
int bar = 10;
int baz = foo + bar
<
Otherwise they would become: >
int foo = 5;
int bar = 10;
int baz = foo + bar
<
If you want the spaces to be removed only if |'NERDSpaceDelims'| is set then
set NERDRemoveExtraSpaces to 0.
------------------------------------------------------------------------------
*'NERDLPlace'*
*'NERDRPlace'*
Values: arbitrary string.
Default:
NERDLPlace: "[>"
NERDRPlace: "<]"
These options are used to control the strings used as place-holder delimiters.
Place holder delimiters are used when performing nested commenting when the
filetype supports commenting styles with both left and right delimiters.
To set these options use lines like: >
let NERDLPlace="FOO"
let NERDRPlace="BAR"
<
Following the above example, if we have line of c code: >
/* int horse */
<
and we comment it with <leader>cn it will be changed to: >
/*FOO int horse BAR*/
<
When we uncomment this line it will go back to what it was.
------------------------------------------------------------------------------
*'NERDMenuMode'*
Values: 0, 1, 2, 3.
Default: 3
This option can take 4 values:
"0": Turns the menu off.
"1": Turns the 'comment' menu on with no menu shortcut.
"2": Turns the 'comment 'menu on with <alt>-c as the shortcut.
"3": Turns the 'Plugin -> comment' menu on with <alt>-c as the shortcut.
------------------------------------------------------------------------------
*'NERDUsePlaceHolders'*
Values: 0 or 1.
Default 1.
This option is used to specify whether place-holder delimiters should be used
when creating a nested comment.
------------------------------------------------------------------------------
*'NERDSpaceDelims'*
Values: 0 or 1.
Default 0.
Some people prefer a space after the left delimiter and before the right
delimiter like this: >
/* int foo=2; */
<
as opposed to this: >
/*int foo=2;*/
<
If you want spaces to be added then set NERDSpaceDelims to 1 in your vimrc.
See also |'NERDRemoveExtraSpaces'|.
------------------------------------------------------------------------------
*'NERDCompactSexyComs'*
Values: 0 or 1.
Default 0.
Some people may want their sexy comments to be like this: >
/* Hi There!
* This is a sexy comment
* in c */
<
As opposed to like this: >
/*
* Hi There!
* This is a sexy comment
* in c
*/
<
If this option is set to 1 then the top style will be used.
------------------------------------------------------------------------------
*'NERDDefaultNesting'*
Values: 0 or 1.
Default 1.
When this option is set to 1, comments are nested automatically. That is, if
you hit <leader>cc on a line that is already commented it will be commented
again.
------------------------------------------------------------------------------
3.3 Default delimiter customisation *NERDComDefaultDelims*
If you want the NERD commenter to use the alternative delimiters for a
specific filetype by default then put a line of this form into your vimrc: >
let NERD_<filetype>_alt_style=1
<
Example: java uses // style comments by default, but you want it to default to
/* */ style comments instead. You would put this line in your vimrc: >
let NERD_java_alt_style=1
<
See |NERDComAltDelim| for switching commenting styles at runtime.
==============================================================================
5. Key mapping customisation *NERDComMappings*
To change a mapping just map another key combo to the internal <plug> mapping.
For example, to remap the |NERDComComment| mapping to ",omg" you would put
this line in your vimrc: >
map ,omg <plug>NERDCommenterComment
<
This will stop the corresponding default mappings from being created.
See the help for the mapping in question to see which <plug> mapping to
map to.
See also |'NERDCreateDefaultMappings'|.
==============================================================================
6. Issues with the script *NERDComIssues*
------------------------------------------------------------------------------
6.1 Delimiter detection heuristics *NERDComHeuristics*
Heuristics are used to distinguish the real comment delimiters
Because we have comment mappings that place delimiters in the middle of lines,
removing comment delimiters is a bit tricky. This is because if comment
delimiters appear in a line doesnt mean they really ARE delimiters. For
example, Java uses // comments but the line >
System.out.println("//");
<
clearly contains no real comment delimiters.
To distinguish between ``real'' comment delimiters and ``fake'' ones we use a
set of heuristics. For example, one such heuristic states that any comment
delimiter that has an odd number of non-escaped " characters both preceding
and following it on the line is not a comment because it is probably part of a
string. These heuristics, while usually pretty accurate, will not work for all
cases.
------------------------------------------------------------------------------
6.2 Nesting issues *NERDComNesting*
If we have some line of code like this: >
/*int foo */ = /*5 + 9;*/
<
This will not be uncommented legally. The NERD commenter will remove the
"outter most" delimiters so the line will become: >
int foo */ = /*5 + 9;
<
which almost certainly will not be what you want. Nested sets of comments will
uncomment fine though. Eg: >
/*int/* foo =*/ 5 + 9;*/
<
will become: >
int/* foo =*/ 5 + 9;
<
(Note that in the above examples I have deliberately not used place holders
for simplicity)
==============================================================================
7. About *NERDComAbout*
The author of the NERD commenter is Martyzillatron --- the half robot, half
dinosaur bastard son of Megatron and Godzilla. He enjoys destroying
metropolises and eating tourist busses.
Drop him a line at martin_grenfell at msn.com. He would love to hear from you.
its a lonely life being the worlds premier terror machine. How would you feel
if your face looked like a toaster and a t-rex put together? :(
The latest stable versions can be found at
http://www.vim.org/scripts/script.php?script_id=1218
The latest dev versions are on github
http://github.com/scrooloose/nerdcommenter
==============================================================================
8. Changelog *NERDComChangelog*
2.3.0
- remove all filetypes which have a &commentstring in the standard vim
runtime for vim > 7.0 unless the script stores an alternate set of
delimiters
- make the script complain if the user doesnt have filetype plugins enabled
- use <leader> instead of comma to start the default mappings
- fix a couple of bugs with sexy comments - thanks to Tim Smart
- lots of refactoring
2.2.2
- remove the NERDShutup option and the message is suppresses, this makes
the plugin silently rely on &commentstring for unknown filetypes.
- add support for dhcpd, limits, ntp, resolv, rgb, sysctl, udevconf and
udevrules. Thanks to Thilo Six.
- match filetypes case insensitively
- add support for mp (metapost), thanks to Andrey Skvortsov.
- add support for htmlcheetah, thanks to Simon Hengel.
- add support for javacc, thanks to Matt Tolton.
- make <%# %> the default delims for eruby, thanks to tpope.
- add support for javascript.jquery, thanks to Ivan Devat.
- add support for cucumber and pdf. Fix sass and railslog delims,
thanks to tpope
2.2.1
- add support for newlisp and clojure, thanks to Matthew Lee Hinman.
- fix automake comments, thanks to Elias Pipping
- make haml comments default to -# with / as the alternative delimiter,
thanks to tpope
- add support for actionscript and processing thanks to Edwin Benavides
- add support for ps1 (powershell), thanks to Jason Mills
- add support for hostsaccess, thanks to Thomas Rowe
- add support for CVScommit
- add support for asciidoc, git and gitrebase. Thanks to Simon Ruderich.
- use # for gitcommit comments, thanks to Simon Ruderich.
- add support for mako and genshi, thanks to Keitheis.
- add support for conkyrc, thanks to David
- add support for SVNannotate, thanks to Miguel Jaque Barbero.
- add support for sieve, thanks to Stefan Walk
- add support for objj, thanks to Adam Thorsen.
2.2.0
- rewrote the mappings system to be more "standard".
- removed all the mapping options. Now, mappings to <plug> mappings are
used
- see :help NERDComMappings, and :help NERDCreateDefaultMappings for
more info
- remove "prepend comments" and "right aligned comments".
- add support for applescript, calbire, man, SVNcommit, potwiki, txt2tags and SVNinfo.
Thanks to nicothakis, timberke, sgronblo, mntnoe, Bernhard Grotz, John
O'Shea, François and Giacomo Mariani respectively.
- bugfix for haskell delimiters. Thanks to mntnoe.
2.1.18
- add support for llvm. Thanks to nicothakis.
- add support for xquery. Thanks to Phillip Kovalev.
2.1.17
- fixed haskell delimiters (hackily). Thanks to Elias Pipping.
- add support for mailcap. Thanks to Pascal Brueckner.
- add support for stata. Thanks to Jerónimo Carballo.
- applied a patch from ewfalor to fix an error in the help file with the
NERDMapleader doc
- disable the insert mode ctrl-c mapping by default, see :help
NERDComInsertComment if you wish to restore it
==============================================================================
9. Credits *NERDComCredits*
Thanks to the follow people for suggestions and patches:
Nick Brettell
Matthew Hawkins
Mathieu Clabaut
Greg Searle
Nguyen
Litchi
Jorge Scandaliaris
Shufeng Zheng
Martin Stubenschrott
Markus Erlmann
Brent Rice
Richard Willis
Igor Prischepoff
Harry
David Bourgeois
Eike Von Seggern
Torsten Blix
Alexander Bosecke
Stefano Zacchiroli
Norick Chen
Joseph Barker
Gary Church
Tim Carey-Smith
Markus Klinik
Anders
Seth Mason
James Hales
Heptite
Cheng Fang
Yongwei Wu
David Miani
Jeremy Hinegardner
Marco
Ingo Karkat
Zhang Shuhan
tpope
Ben Schmidt
David Fishburn
Erik Falor
JaGoTerr
Elias Pipping
mntnoe
Mark S.
Thanks to the following people for sending me new filetypes to support:
The hackers The filetypes~
Sam R verilog
Jonathan Derque context, plaintext and mail
Vigil fetchmail
Michael Brunner kconfig
Antono Vasiljev netdict
Melissa Reid omlet
Ilia N Ternovich quickfix
John O'Shea RTF, SVNcommitlog and vcscommit, SVNCommit
Anders occam
Mark Woodward csv
fREW gentoo-package-mask,
gentoo-package-keywords,
gentoo-package-use, and vo_base
Alexey verilog_systemverilog, systemverilog
Lizendir fstab
Michael Böhler autoit, autohotkey and docbk
Aaron Small cmake
Ramiro htmldjango and django
Stefano Zacchiroli debcontrol, debchangelog, mkd
Alex Tarkovsky ebuild and eclass
Jorge Rodrigues gams
Rainer Müller Objective C
Jason Mills Groovy, ps1
Normandie Azucena vera
Florian Apolloner ldif
David Fishburn lookupfile
Niels Aan de Brugh rst
Don Hatlestad ahk
Christophe Benz Desktop and xsd
Eyolf Østrem lilypond, bbx and lytex
Ingo Karkat dosbatch
Nicolas Weber markdown, objcpp
tinoucas gentoo-conf-d
Greg Weber D, haml
Bruce Sherrod velocity
timberke cobol, calibre
Aaron Schaefer factor
Mr X asterisk, mplayerconf
Kuchma Michael plsql
Brett Warneke spectre
Pipp lhaskell
Renald Buter scala
Vladimir Lomov asymptote
Marco mrxvtrc, aap
nicothakis SVNAnnotate, CVSAnnotate, SVKAnnotate,
SVNdiff, gitAnnotate, gitdiff, dtrace
llvm, applescript
Chen Xing Wikipedia
Jacobo Diaz dakota, patran
Li Jin gentoo-env-d, gentoo-init-d,
gentoo-make-conf, grub, modconf, sudoers
SpookeyPeanut rib
Greg Jandl pyrex/cython
Christophe Benz services, gitcommit
A Pontus vimperator
Stromnov slice, bzr
Martin Kustermann pamconf
Indriði Einarsson mason
Chris map
Krzysztof A. Adamski group
Pascal Brueckner mailcap
Jerónimo Carballo stata
Phillip Kovalev xquery
Bernhard Grotz potwiki
sgronblo man
François txt2tags
Giacomo Mariani SVNinfo
Matthew Lee Hinman newlisp, clojure
Elias Pipping automake
Edwin Benavides actionscript, processing
Thomas Rowe hostsaccess
Simon Ruderich asciidoc, git, gitcommit, gitrebase
Keitheis mako, genshi
David conkyrc
Miguel Jaque Barbero SVNannotate
Stefan Walk sieve
Adam Thorsen objj
Thilo Six dhcpd, limits, ntp, resolv, rgb, sysctl,
udevconf, udevrules
Andrey Skvortsov mp
Simon Hengel htmlcheetah
Matt Tolton javacc
Ivan Devat javascript.jquery
tpope cucumber,pdf
==============================================================================
10. License *NERDComLicense*
The NERD commenter is released under the wtfpl.
See http://sam.zoy.org/wtfpl/COPYING.

View File

@ -0,0 +1,48 @@
'NERDAllowAnyVisualDelims' NERD_commenter.txt /*'NERDAllowAnyVisualDelims'*
'NERDBlockComIgnoreEmpty' NERD_commenter.txt /*'NERDBlockComIgnoreEmpty'*
'NERDCommentWholeLinesInVMode' NERD_commenter.txt /*'NERDCommentWholeLinesInVMode'*
'NERDCompactSexyComs' NERD_commenter.txt /*'NERDCompactSexyComs'*
'NERDCreateDefaultMappings' NERD_commenter.txt /*'NERDCreateDefaultMappings'*
'NERDDefaultNesting' NERD_commenter.txt /*'NERDDefaultNesting'*
'NERDLPlace' NERD_commenter.txt /*'NERDLPlace'*
'NERDMenuMode' NERD_commenter.txt /*'NERDMenuMode'*
'NERDRPlace' NERD_commenter.txt /*'NERDRPlace'*
'NERDRemoveAltComs' NERD_commenter.txt /*'NERDRemoveAltComs'*
'NERDRemoveExtraSpaces' NERD_commenter.txt /*'NERDRemoveExtraSpaces'*
'NERDSpaceDelims' NERD_commenter.txt /*'NERDSpaceDelims'*
'NERDUsePlaceHolders' NERD_commenter.txt /*'NERDUsePlaceHolders'*
'loaded_nerd_comments' NERD_commenter.txt /*'loaded_nerd_comments'*
NERDComAbout NERD_commenter.txt /*NERDComAbout*
NERDComAlignedComment NERD_commenter.txt /*NERDComAlignedComment*
NERDComAltDelim NERD_commenter.txt /*NERDComAltDelim*
NERDComAppendComment NERD_commenter.txt /*NERDComAppendComment*
NERDComChangelog NERD_commenter.txt /*NERDComChangelog*
NERDComComment NERD_commenter.txt /*NERDComComment*
NERDComCredits NERD_commenter.txt /*NERDComCredits*
NERDComDefaultDelims NERD_commenter.txt /*NERDComDefaultDelims*
NERDComEOLComment NERD_commenter.txt /*NERDComEOLComment*
NERDComFunctionality NERD_commenter.txt /*NERDComFunctionality*
NERDComFunctionalityDetails NERD_commenter.txt /*NERDComFunctionalityDetails*
NERDComFunctionalitySummary NERD_commenter.txt /*NERDComFunctionalitySummary*
NERDComHeuristics NERD_commenter.txt /*NERDComHeuristics*
NERDComInsertComment NERD_commenter.txt /*NERDComInsertComment*
NERDComInstallation NERD_commenter.txt /*NERDComInstallation*
NERDComInvertComment NERD_commenter.txt /*NERDComInvertComment*
NERDComIssues NERD_commenter.txt /*NERDComIssues*
NERDComLicense NERD_commenter.txt /*NERDComLicense*
NERDComMappings NERD_commenter.txt /*NERDComMappings*
NERDComMinimalComment NERD_commenter.txt /*NERDComMinimalComment*
NERDComNERDComment NERD_commenter.txt /*NERDComNERDComment*
NERDComNestedComment NERD_commenter.txt /*NERDComNestedComment*
NERDComNesting NERD_commenter.txt /*NERDComNesting*
NERDComOptions NERD_commenter.txt /*NERDComOptions*
NERDComOptionsDetails NERD_commenter.txt /*NERDComOptionsDetails*
NERDComOptionsSummary NERD_commenter.txt /*NERDComOptionsSummary*
NERDComSexyComment NERD_commenter.txt /*NERDComSexyComment*
NERDComSexyComments NERD_commenter.txt /*NERDComSexyComments*
NERDComToggleComment NERD_commenter.txt /*NERDComToggleComment*
NERDComUncommentLine NERD_commenter.txt /*NERDComUncommentLine*
NERDComYankComment NERD_commenter.txt /*NERDComYankComment*
NERDCommenter NERD_commenter.txt /*NERDCommenter*
NERDCommenterContents NERD_commenter.txt /*NERDCommenterContents*
NERD_commenter.txt NERD_commenter.txt /*NERD_commenter.txt*

View File

@ -0,0 +1,54 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=1658
Grab the latest dev version from github: https://github.com/scrooloose/nerdtree.
What is this "NERD tree"??
Check out this demo http://www.flickr.com/photos/30496122@N07/2862367534/sizes/o/
The NERD tree allows you to explore your filesystem and to open files and
directories. It presents the filesystem to you in the form of a tree which you
manipulate with the keyboard and/or mouse. It also allows you to perform
simple filesystem operations.
The following features and functionality are provided by the NERD tree:
* Files and directories are displayed in a hierarchical tree structure
* Different highlighting is provided for the following types of nodes:
* files
* directories
* sym-links
* windows .lnk files
* read-only files
* executable files
* Many (customisable) mappings are provided to manipulate the tree:
* Mappings to open/close/explore directory nodes
* Mappings to open files in new/existing windows/tabs
* Mappings to change the current root of the tree
* Mappings to navigate around the tree
* ...
* Directories and files can be bookmarked.
* Most NERD tree navigation can also be done with the mouse
* Filtering of tree content (can be toggled at runtime)
* custom file filters to prevent e.g. vim backup files being displayed
* optional displaying of hidden files (. files)
* files can be "turned off" so that only directories are displayed
* A textual filesystem menu is provided which allows you to
create/delete/move file and directory nodes as well as copy (for
supported OSs)
* The position and size of the NERD tree window can be customised
* The order in which the nodes in the tree are listed can be customised.
* A model of your filesystem is created/maintained as you explore it. This
has several advantages:
* All filesystem information is cached and is only re-read on demand
* If you revisit a part of the tree that you left earlier in your
session, the directory nodes will be opened/closed as you left them
* The script remembers the cursor position and window position in the NERD
tree so you can toggle it off (or just close the tree window) and then
reopen it (with NERDTreeToggle) the NERD tree window will appear exactly
as you left it
* You can have a separate NERD tree for each tab, share trees across tabs,
or a mix of both.
* By default the script overrides the default file browser (netw), so if
you :edit a directory a (slighly modified) NERD tree will appear in the
current window

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,87 @@
'NERDChristmasTree' NERD_tree.txt /*'NERDChristmasTree'*
'NERDTreeAutoCenter' NERD_tree.txt /*'NERDTreeAutoCenter'*
'NERDTreeAutoCenterThreshold' NERD_tree.txt /*'NERDTreeAutoCenterThreshold'*
'NERDTreeBookmarksFile' NERD_tree.txt /*'NERDTreeBookmarksFile'*
'NERDTreeCaseSensitiveSort' NERD_tree.txt /*'NERDTreeCaseSensitiveSort'*
'NERDTreeChDirMode' NERD_tree.txt /*'NERDTreeChDirMode'*
'NERDTreeDirArrows' NERD_tree.txt /*'NERDTreeDirArrows'*
'NERDTreeHighlightCursorline' NERD_tree.txt /*'NERDTreeHighlightCursorline'*
'NERDTreeHijackNetrw' NERD_tree.txt /*'NERDTreeHijackNetrw'*
'NERDTreeIgnore' NERD_tree.txt /*'NERDTreeIgnore'*
'NERDTreeMinimalUI' NERD_tree.txt /*'NERDTreeMinimalUI'*
'NERDTreeMouseMode' NERD_tree.txt /*'NERDTreeMouseMode'*
'NERDTreeQuitOnOpen' NERD_tree.txt /*'NERDTreeQuitOnOpen'*
'NERDTreeShowBookmarks' NERD_tree.txt /*'NERDTreeShowBookmarks'*
'NERDTreeShowFiles' NERD_tree.txt /*'NERDTreeShowFiles'*
'NERDTreeShowHidden' NERD_tree.txt /*'NERDTreeShowHidden'*
'NERDTreeShowLineNumbers' NERD_tree.txt /*'NERDTreeShowLineNumbers'*
'NERDTreeSortOrder' NERD_tree.txt /*'NERDTreeSortOrder'*
'NERDTreeStatusline' NERD_tree.txt /*'NERDTreeStatusline'*
'NERDTreeWinPos' NERD_tree.txt /*'NERDTreeWinPos'*
'NERDTreeWinSize' NERD_tree.txt /*'NERDTreeWinSize'*
'loaded_nerd_tree' NERD_tree.txt /*'loaded_nerd_tree'*
:NERDTree NERD_tree.txt /*:NERDTree*
:NERDTreeClose NERD_tree.txt /*:NERDTreeClose*
:NERDTreeFind NERD_tree.txt /*:NERDTreeFind*
:NERDTreeFromBookmark NERD_tree.txt /*:NERDTreeFromBookmark*
:NERDTreeMirror NERD_tree.txt /*:NERDTreeMirror*
:NERDTreeToggle NERD_tree.txt /*:NERDTreeToggle*
NERDTree NERD_tree.txt /*NERDTree*
NERDTree-? NERD_tree.txt /*NERDTree-?*
NERDTree-A NERD_tree.txt /*NERDTree-A*
NERDTree-B NERD_tree.txt /*NERDTree-B*
NERDTree-C NERD_tree.txt /*NERDTree-C*
NERDTree-C-J NERD_tree.txt /*NERDTree-C-J*
NERDTree-C-K NERD_tree.txt /*NERDTree-C-K*
NERDTree-D NERD_tree.txt /*NERDTree-D*
NERDTree-F NERD_tree.txt /*NERDTree-F*
NERDTree-I NERD_tree.txt /*NERDTree-I*
NERDTree-J NERD_tree.txt /*NERDTree-J*
NERDTree-K NERD_tree.txt /*NERDTree-K*
NERDTree-O NERD_tree.txt /*NERDTree-O*
NERDTree-P NERD_tree.txt /*NERDTree-P*
NERDTree-R NERD_tree.txt /*NERDTree-R*
NERDTree-T NERD_tree.txt /*NERDTree-T*
NERDTree-U NERD_tree.txt /*NERDTree-U*
NERDTree-X NERD_tree.txt /*NERDTree-X*
NERDTree-cd NERD_tree.txt /*NERDTree-cd*
NERDTree-contents NERD_tree.txt /*NERDTree-contents*
NERDTree-e NERD_tree.txt /*NERDTree-e*
NERDTree-f NERD_tree.txt /*NERDTree-f*
NERDTree-gi NERD_tree.txt /*NERDTree-gi*
NERDTree-go NERD_tree.txt /*NERDTree-go*
NERDTree-gs NERD_tree.txt /*NERDTree-gs*
NERDTree-i NERD_tree.txt /*NERDTree-i*
NERDTree-m NERD_tree.txt /*NERDTree-m*
NERDTree-o NERD_tree.txt /*NERDTree-o*
NERDTree-p NERD_tree.txt /*NERDTree-p*
NERDTree-q NERD_tree.txt /*NERDTree-q*
NERDTree-r NERD_tree.txt /*NERDTree-r*
NERDTree-s NERD_tree.txt /*NERDTree-s*
NERDTree-t NERD_tree.txt /*NERDTree-t*
NERDTree-u NERD_tree.txt /*NERDTree-u*
NERDTree-x NERD_tree.txt /*NERDTree-x*
NERDTreeAPI NERD_tree.txt /*NERDTreeAPI*
NERDTreeAbout NERD_tree.txt /*NERDTreeAbout*
NERDTreeAddKeyMap() NERD_tree.txt /*NERDTreeAddKeyMap()*
NERDTreeAddMenuItem() NERD_tree.txt /*NERDTreeAddMenuItem()*
NERDTreeAddMenuSeparator() NERD_tree.txt /*NERDTreeAddMenuSeparator()*
NERDTreeAddSubmenu() NERD_tree.txt /*NERDTreeAddSubmenu()*
NERDTreeBookmarkCommands NERD_tree.txt /*NERDTreeBookmarkCommands*
NERDTreeBookmarkTable NERD_tree.txt /*NERDTreeBookmarkTable*
NERDTreeBookmarks NERD_tree.txt /*NERDTreeBookmarks*
NERDTreeChangelog NERD_tree.txt /*NERDTreeChangelog*
NERDTreeCredits NERD_tree.txt /*NERDTreeCredits*
NERDTreeFunctionality NERD_tree.txt /*NERDTreeFunctionality*
NERDTreeGlobalCommands NERD_tree.txt /*NERDTreeGlobalCommands*
NERDTreeInvalidBookmarks NERD_tree.txt /*NERDTreeInvalidBookmarks*
NERDTreeKeymapAPI NERD_tree.txt /*NERDTreeKeymapAPI*
NERDTreeLicense NERD_tree.txt /*NERDTreeLicense*
NERDTreeMappings NERD_tree.txt /*NERDTreeMappings*
NERDTreeMenu NERD_tree.txt /*NERDTreeMenu*
NERDTreeMenuAPI NERD_tree.txt /*NERDTreeMenuAPI*
NERDTreeOptionDetails NERD_tree.txt /*NERDTreeOptionDetails*
NERDTreeOptionSummary NERD_tree.txt /*NERDTreeOptionSummary*
NERDTreeOptions NERD_tree.txt /*NERDTreeOptions*
NERDTreeRender() NERD_tree.txt /*NERDTreeRender()*
NERD_tree.txt NERD_tree.txt /*NERD_tree.txt*

View File

@ -0,0 +1,41 @@
" ============================================================================
" File: exec_menuitem.vim
" Description: plugin for NERD Tree that provides an execute file menu item
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" Last Change: 22 July, 2009
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
" ============================================================================
if exists("g:loaded_nerdtree_exec_menuitem")
finish
endif
let g:loaded_nerdtree_exec_menuitem = 1
call NERDTreeAddMenuItem({
\ 'text': '(!)Execute file',
\ 'shortcut': '!',
\ 'callback': 'NERDTreeExecFile',
\ 'isActiveCallback': 'NERDTreeExecFileActive' })
function! NERDTreeExecFileActive()
let node = g:NERDTreeFileNode.GetSelected()
return !node.path.isDirectory && node.path.isExecutable
endfunction
function! NERDTreeExecFile()
let treenode = g:NERDTreeFileNode.GetSelected()
echo "==========================================================\n"
echo "Complete the command to execute (add arguments etc):\n"
let cmd = treenode.path.str({'escape': 1})
let cmd = input(':!', cmd . ' ')
if cmd != ''
exec ':!' . cmd
else
echo "Aborted"
endif
endfunction

View File

@ -0,0 +1,224 @@
" ============================================================================
" File: fs_menu.vim
" Description: plugin for the NERD Tree that provides a file system menu
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" Last Change: 17 July, 2009
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
" ============================================================================
if exists("g:loaded_nerdtree_fs_menu")
finish
endif
let g:loaded_nerdtree_fs_menu = 1
call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
if has("gui_mac") || has("gui_macvim")
call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'})
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'})
call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'})
endif
if g:NERDTreePath.CopyingSupported()
call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
endif
"FUNCTION: s:echo(msg){{{1
function! s:echo(msg)
redraw
echomsg "NERDTree: " . a:msg
endfunction
"FUNCTION: s:echoWarning(msg){{{1
function! s:echoWarning(msg)
echohl warningmsg
call s:echo(a:msg)
echohl normal
endfunction
"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1
"prints out the given msg and, if the user responds by pushing 'y' then the
"buffer with the given bufnum is deleted
"
"Args:
"bufnum: the buffer that may be deleted
"msg: a message that will be echoed to the user asking them if they wish to
" del the buffer
function! s:promptToDelBuffer(bufnum, msg)
echo a:msg
if nr2char(getchar()) ==# 'y'
exec "silent bdelete! " . a:bufnum
endif
endfunction
"FUNCTION: NERDTreeAddNode(){{{1
function! NERDTreeAddNode()
let curDirNode = g:NERDTreeDirNode.GetSelected()
let newNodeName = input("Add a childnode\n".
\ "==========================================================\n".
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
\ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file")
if newNodeName ==# ''
call s:echo("Node Creation Aborted.")
return
endif
try
let newPath = g:NERDTreePath.Create(newNodeName)
let parentNode = b:NERDTreeRoot.findNode(newPath.getParent())
let newTreeNode = g:NERDTreeFileNode.New(newPath)
if parentNode.isOpen || !empty(parentNode.children)
call parentNode.addChild(newTreeNode, 1)
call NERDTreeRender()
call newTreeNode.putCursorHere(1, 0)
endif
catch /^NERDTree/
call s:echoWarning("Node Not Created.")
endtry
endfunction
"FUNCTION: NERDTreeMoveNode(){{{1
function! NERDTreeMoveNode()
let curNode = g:NERDTreeFileNode.GetSelected()
let newNodePath = input("Rename the current node\n" .
\ "==========================================================\n" .
\ "Enter the new path for the node: \n" .
\ "", curNode.path.str(), "file")
if newNodePath ==# ''
call s:echo("Node Renaming Aborted.")
return
endif
try
let bufnum = bufnr(curNode.path.str())
call curNode.rename(newNodePath)
call NERDTreeRender()
"if the node is open in a buffer, ask the user if they want to
"close that buffer
if bufnum != -1
let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
call s:promptToDelBuffer(bufnum, prompt)
endif
call curNode.putCursorHere(1, 0)
redraw
catch /^NERDTree/
call s:echoWarning("Node Not Renamed.")
endtry
endfunction
" FUNCTION: NERDTreeDeleteNode() {{{1
function! NERDTreeDeleteNode()
let currentNode = g:NERDTreeFileNode.GetSelected()
let confirmed = 0
if currentNode.path.isDirectory
let choice =input("Delete the current node\n" .
\ "==========================================================\n" .
\ "STOP! To delete this entire directory, type 'yes'\n" .
\ "" . currentNode.path.str() . ": ")
let confirmed = choice ==# 'yes'
else
echo "Delete the current node\n" .
\ "==========================================================\n".
\ "Are you sure you wish to delete the node:\n" .
\ "" . currentNode.path.str() . " (yN):"
let choice = nr2char(getchar())
let confirmed = choice ==# 'y'
endif
if confirmed
try
call currentNode.delete()
call NERDTreeRender()
"if the node is open in a buffer, ask the user if they want to
"close that buffer
let bufnum = bufnr(currentNode.path.str())
if buflisted(bufnum)
let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
call s:promptToDelBuffer(bufnum, prompt)
endif
redraw
catch /^NERDTree/
call s:echoWarning("Could not remove node")
endtry
else
call s:echo("delete aborted")
endif
endfunction
" FUNCTION: NERDTreeCopyNode() {{{1
function! NERDTreeCopyNode()
let currentNode = g:NERDTreeFileNode.GetSelected()
let newNodePath = input("Copy the current node\n" .
\ "==========================================================\n" .
\ "Enter the new path to copy the node to: \n" .
\ "", currentNode.path.str(), "file")
if newNodePath != ""
"strip trailing slash
let newNodePath = substitute(newNodePath, '\/$', '', '')
let confirmed = 1
if currentNode.path.copyingWillOverwrite(newNodePath)
call s:echo("Warning: copying may overwrite files! Continue? (yN)")
let choice = nr2char(getchar())
let confirmed = choice ==# 'y'
endif
if confirmed
try
let newNode = currentNode.copy(newNodePath)
if !empty(newNode)
call NERDTreeRender()
call newNode.putCursorHere(0, 0)
endif
catch /^NERDTree/
call s:echoWarning("Could not copy node")
endtry
endif
else
call s:echo("Copy aborted.")
endif
redraw
endfunction
function! NERDTreeQuickLook()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'")
endif
endfunction
function! NERDTreeRevealInFinder()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let x = system("open -R '" . treenode.path.str() . "'")
endif
endfunction
function! NERDTreeExecuteFile()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let x = system("open '" . treenode.path.str() . "'")
endif
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,88 @@
let s:tree_up_dir_line = '.. (up a dir)'
"NERDTreeFlags are syntax items that should be invisible, but give clues as to
"how things should be highlighted
syn match NERDTreeFlag #\~#
syn match NERDTreeFlag #\[RO\]#
"highlighting for the .. (up dir) line at the top of the tree
execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
"highlighting for the ~/+ symbols for the directory nodes
syn match NERDTreeClosable #\~\<#
syn match NERDTreeClosable #\~\.#
syn match NERDTreeOpenable #+\<#
syn match NERDTreeOpenable #+\.#he=e-1
"highlighting for the tree structural parts
syn match NERDTreePart #|#
syn match NERDTreePart #`#
syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart
"quickhelp syntax elements
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag
syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey
syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey
syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
"highlighting for readonly files
syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
"highlighting for sym links
syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash
"highlighing for directory nodes and file nodes
syn match NERDTreeDirSlash #/#
syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
syn match NERDTreeCWD #^[</].*$#
"highlighting for bookmarks
syn match NERDTreeBookmark # {.*}#hs=s+1
"highlighting for the bookmarks table
syn match NERDTreeBookmarksLeader #^>#
syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader
syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader
syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader
if exists("g:NERDChristmasTree") && g:NERDChristmasTree
hi def link NERDTreePart Special
hi def link NERDTreePartFile Type
hi def link NERDTreeFile Normal
hi def link NERDTreeExecFile Title
hi def link NERDTreeDirSlash Identifier
hi def link NERDTreeClosable Type
else
hi def link NERDTreePart Normal
hi def link NERDTreePartFile Normal
hi def link NERDTreeFile Normal
hi def link NERDTreeClosable Title
endif
hi def link NERDTreeBookmarksHeader statement
hi def link NERDTreeBookmarksLeader ignore
hi def link NERDTreeBookmarkName Identifier
hi def link NERDTreeBookmark normal
hi def link NERDTreeHelp String
hi def link NERDTreeHelpKey Identifier
hi def link NERDTreeHelpCommand Identifier
hi def link NERDTreeHelpTitle Macro
hi def link NERDTreeToggleOn Question
hi def link NERDTreeToggleOff WarningMsg
hi def link NERDTreeDir Directory
hi def link NERDTreeUp Directory
hi def link NERDTreeCWD Statement
hi def link NERDTreeLink Macro
hi def link NERDTreeOpenable Title
hi def link NERDTreeFlag ignore
hi def link NERDTreeRO WarningMsg
hi def link NERDTreeBookmark Statement
hi def link NERDTreeCurrentNode Search

2
vim/bundle/Vundle.vim/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
doc/tags
.netrwhist

View File

@ -0,0 +1,111 @@
Pull Requests
=============
1. Please squash your commits to minimize the log pollution. This is more of a convenience for the maintainer who pulls. If you are unfamiliar, see [here](http://ariejan.net/2011/07/05/git-squash-your-latests-commits-into-one/).
2. Clearly describe what you aim to fix or add to Vundle.
3. Try to minimize code changes and use existing style/functions.
Issues
======
## Check For Answers
Before submitting an issue, be sure to check the following places for answers.
1. Vundle docs at [`:h vundle`](https://github.com/gmarik/Vundle.vim/blob/master/doc/vundle.txt).
2. The [FAQ](https://github.com/gmarik/Vundle.vim/search).
3. [Search](https://github.com/gmarik/Vundle.vim/search) the repository for related issues.
## Try To Eliminate Your Vimrc
In order to make sure it isn't just `.vimrc` replace your own config file with the [minimal vimrc](https://github.com/gmarik/Vundle.vim/blob/master/test/minirc.vim). Clear out bundles and then try to reproduce.
If the problem stops, likely there is an issue in your user configuration. You can incrementally add back your user changes to the minimal file testing the bug each time. This will allow you to slowly bisect the issue. You may want to test one plugin at a time.
If you can still reproduce the problem, try to find the smallest `.vimrc` config file that creates the problem to include later.
## Guidelines
To better respond to issues please follow these general guidelines when explaining the problem.
1. Clearly describe what the error is, if relevant attach output/screenshots.
2. Describe how developers can reproduce the bug, the steps should be from starting Vim.
3. Include your OS, version and architecture. For example, Windows 7 64, Kubuntu 13.04 32, etc...
4. If relevant to reproducing the bug, include the smallest subset of your `.vimrc` that causes the issue. Put this in code tags.
5. At the end of your issue, please put the output of `vim --version` in code tags.
## Example Post
I am using Vim on Kubuntu 13.04 64 bit and I get the following error... (add further explanation here)
To reproduce the bug, use the vimrc file below and run `:BundleInstall`... (continue with steps)
Vimrc:
```
set nocompatible
syntax on
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#rc()
Bundle 'gmarik/Vundle.vim'
Bundle 'relevant/plugin'
filetype plugin indent on
.... more user configs here...
```
Vim Version:
```
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 15 2013 10:58:39)
Included patches: 1-5
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version with GTK2 GUI. Features included (+) or not (-):
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
+balloon_eval +float +mouse_urxvt -tag_any_white
+browse +folding +mouse_xterm +tcl
++builtin_terms -footer +multi_byte +terminfo
+byte_offset +fork() +multi_lang +termresponse
+cindent +gettext -mzscheme +textobjects
+clientserver -hangul_input +netbeans_intg +title
+clipboard +iconv +path_extra +toolbar
+cmdline_compl +insert_expand +perl +user_commands
+cmdline_hist +jumplist +persistent_undo +vertsplit
+cmdline_info +keymap +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak +python +viminfo
+cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con_gui +lua +rightleft +windows
+diff +menu +ruby +writebackup
+digraphs +mksession +scrollbind +X11
+dnd +modify_fname +signs -xfontset
-ebcdic +mouse +smartindent +xim
+emacs_tags +mouseshape -sniff +xsmp_interact
+eval +mouse_dec +startuptime +xterm_clipboard
+ex_extra +mouse_gpm +statusline -xterm_save
+extra_search -mouse_jsbterm -sun_workshop
+farsi +mouse_netterm +syntax
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/harfbuzz -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -I/usr/include/tcl8.5 -D_REENTRANT=1 -D_THREAD_SAFE=1 -D_LARGEFILE64_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib -llua5.1 -Wl,-E -fstack-protector -L/usr/local/lib -L/usr/lib/perl/5.14/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L/usr/lib/x86_64-linux-gnu -ltcl8.5 -ldl -lpthread -lieee -lm -lruby-1.9.1 -lpthread -lrt -ldl -lcrypt -lm -L/usr/lib
```

View File

@ -0,0 +1,7 @@
Copyright (C) 2010 http://github.com/gmarik
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,158 @@
## [Help Maintain Vundle](https://github.com/gmarik/Vundle.vim/issues/383)
## About
[Vundle] is short for _Vim bundle_ and is a [Vim] plugin manager.
[Vundle] allows you to...
* keep track of and [configure] your plugins right in the `.vimrc`
* [install] configured plugins (a.k.a. scripts/bundle)
* [update] configured plugins
* [search] by name all available [Vim scripts]
* [clean] unused plugins up
* run the above actions in a *single keypress* with [interactive mode]
[Vundle] automatically...
* manages the [runtime path] of your installed scripts
* regenerates [help tags] after installing and updating
[Vundle] is undergoing an [interface change], please stay up to date to get latest changes.
[![Gitter-chat](https://badges.gitter.im/gmarik/Vundle.vim.png)](https://gitter.im/gmarik/Vundle.vim) for discussion and support.
![Vundle-installer](http://i.imgur.com/Rueh7Cc.png)
## Quick Start
1. Introduction:
Installation requires [Git] and triggers [`git clone`] for each configured repository to `~/.vim/bundle/` by default.
Curl is required for search.
If you are using Windows, go directly to [Windows setup]. If you run into any issues, please consult the [FAQ].
See [Tips] for some advanced configurations.
2. Set up [Vundle]:
`$ git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim`
3. Configure Plugins:
Put this at the top of your `.vimrc` to use Vundle. Remove plugins you don't need, they are for illustration purposes.
```vim
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
Plugin 'user/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
```
4. Install Plugins:
Launch `vim` and run `:PluginInstall`
To install from command line: `vim +PluginInstall +qall`
## Docs
See the [`:h vundle`](https://github.com/gmarik/Vundle.vim/blob/master/doc/vundle.txt) Vimdoc for more details.
## Changelog
See the [changelog](https://github.com/gmarik/Vundle.vim/blob/master/changelog.md).
## People Using Vundle
see [Examples](https://github.com/gmarik/Vundle.vim/wiki/Examples)
## Contributors
see [Vundle contributors](https://github.com/gmarik/Vundle.vim/graphs/contributors)
*Thank you!*
## Inspiration & Ideas
* [pathogen.vim](http://github.com/tpope/vim-pathogen/)
* [Bundler](https://github.com/bundler/bundler)
* [Scott Bronson](http://github.com/bronson)
## Also
* Vundle was developed and tested with [Vim] 7.3 on OS X, Linux and Windows
* Vundle tries to be as [KISS](http://en.wikipedia.org/wiki/KISS_principle) as possible
## TODO:
[Vundle] is a work in progress, so any ideas and patches are appreciated.
* ✓ activate newly added bundles on `.vimrc` reload or after `:PluginInstall`
* ✓ use preview window for search results
* ✓ Vim documentation
* ✓ put Vundle in `bundles/` too (will fix Vundle help)
* ✓ tests
* ✓ improve error handling
* allow specifying revision/version?
* handle dependencies
* show description in search results
* search by description as well
* make it rock!
[Vundle]:http://github.com/gmarik/Vundle.vim
[Windows setup]:https://github.com/gmarik/Vundle.vim/wiki/Vundle-for-Windows
[FAQ]:https://github.com/gmarik/Vundle.vim/wiki
[Tips]:https://github.com/gmarik/Vundle.vim/wiki/Tips-and-Tricks
[Vim]:http://www.vim.org
[Git]:http://git-scm.com
[`git clone`]:http://gitref.org/creating/#clone
[Vim scripts]:http://vim-scripts.org/vim/scripts.html
[help tags]:http://vimdoc.sourceforge.net/htmldoc/helphelp.html#:helptags
[runtime path]:http://vimdoc.sourceforge.net/htmldoc/options.html#%27runtimepath%27
[configure]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L126-L233
[install]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L234-L254
[update]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L255-L265
[search]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L266-L295
[clean]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L303-L318
[interactive mode]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L319-L360
[interface change]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L372-L396

View File

@ -0,0 +1,83 @@
" Vundle is a shortcut for Vim Bundle and Is a simple plugin manager for Vim
" Author: gmarik
" HomePage: http://github.com/gmarik/Vundle.vim
" Readme: http://github.com/gmarik/Vundle.vim/blob/master/README.md
" Version: 0.10.2
" Plugin Commands
com! -nargs=+ -bar Plugin
\ call vundle#config#bundle(<args>)
com! -nargs=? -bang -complete=custom,vundle#scripts#complete PluginInstall
\ call vundle#installer#new('!' == '<bang>', <q-args>)
com! -nargs=? -bang -complete=custom,vundle#scripts#complete PluginSearch
\ call vundle#scripts#all('!' == '<bang>', <q-args>)
com! -nargs=0 -bang PluginList
\ call vundle#installer#list('!' == '<bang>')
com! -nargs=? -bang PluginClean
\ call vundle#installer#clean('!' == '<bang>')
com! -nargs=0 PluginDocs
\ call vundle#installer#helptags(g:bundles)
" Aliases
com! PluginUpdate PluginInstall!
" Vundle Aliases
com! -nargs=? -bang -complete=custom,vundle#scripts#complete VundleInstall PluginInstall<bang> <args>
com! -nargs=? -bang -complete=custom,vundle#scripts#complete VundleSearch PluginSearch<bang> <args>
com! -nargs=? -bang VundleClean PluginClean<bang>
com! -nargs=0 VundleDocs PluginDocs
com! VundleUpdate PluginInstall!
" Deprecated Commands
com! -nargs=+ Bundle call vundle#config#bundle(<args>)
com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleInstall PluginInstall<bang> <args>
com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleSearch PluginSearch<bang> <args>
com! -nargs=0 -bang BundleList PluginList<bang>
com! -nargs=? -bang BundleClean PluginClean<bang>
com! -nargs=0 BundleDocs PluginDocs
com! BundleUpdate PluginInstall!
" Set up the signs used in the installer window. (See :help signs)
if (has('signs'))
sign define Vu_error text=! texthl=Error
sign define Vu_active text=> texthl=Comment
sign define Vu_todate text=. texthl=Comment
sign define Vu_new text=+ texthl=Comment
sign define Vu_updated text=* texthl=Comment
sign define Vu_deleted text=- texthl=Comment
sign define Vu_helptags text=* texthl=Comment
sign define Vu_pinned text== texthl=Comment
endif
" Set up Vundle. This function has to be called from the users vimrc file.
" This will force Vim to source this file as a side effect which wil define
" the :Plugin command. After calling this function the user can use the
" :Plugin command in the vimrc. It is not possible to do this automatically
" because when loading the vimrc file no plugins where loaded yet.
func! vundle#rc(...) abort
let g:bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1)
let g:updated_bundles = []
let g:vundle_log = []
let g:vundle_changelog = ['Updated Plugins:']
call vundle#config#init()
endf
" Alternative to vundle#rc, offers speed up by modifying rtp only when end()
" called later.
func! vundle#begin(...) abort
let g:vundle_lazy_load = 1
call call('vundle#rc', a:000)
endf
" Finishes putting plugins on the rtp.
func! vundle#end(...) abort
unlet g:vundle_lazy_load
call vundle#config#activate_bundles()
endf
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:

View File

@ -0,0 +1,278 @@
" ---------------------------------------------------------------------------
" Add a plugin to the runtimepath.
"
" arg -- a string specifying the plugin
" ... -- a dictionary of options for the plugin
" return -- the return value from vundle#config#init_bundle()
" ---------------------------------------------------------------------------
func! vundle#config#bundle(arg, ...)
let bundle = vundle#config#init_bundle(a:arg, a:000)
if !s:check_bundle_name(bundle)
return
endif
if exists('g:vundle_lazy_load') && g:vundle_lazy_load
call add(g:bundles, bundle)
else
call s:rtp_rm_a()
call add(g:bundles, bundle)
call s:rtp_add_a()
call s:rtp_add_defaults()
endif
return bundle
endf
" ---------------------------------------------------------------------------
" When lazy bundle load is used (begin/end functions), add all configured
" bundles to runtimepath and reorder appropriately.
" ---------------------------------------------------------------------------
func! vundle#config#activate_bundles()
call s:rtp_add_a()
call s:rtp_add_defaults()
endf
" ---------------------------------------------------------------------------
" Initialize Vundle.
"
" Start a new bundles list and make sure the runtimepath does not contain
" directories from a previous call. In theory, this should only be called
" once.
" ---------------------------------------------------------------------------
func! vundle#config#init()
if !exists('g:bundles') | let g:bundles = [] | endif
call s:rtp_rm_a()
let g:bundles = []
let g:bundle_names = {}
endf
" ---------------------------------------------------------------------------
" Add a list of bundles to the runtimepath and source them.
"
" bundles -- a list of bundle objects
" ---------------------------------------------------------------------------
func! vundle#config#require(bundles) abort
for b in a:bundles
call s:rtp_add(b.rtpath)
call s:rtp_add(g:bundle_dir)
" TODO: it has to be relative rtpath, not bundle.name
exec 'runtime! '.b.name.'/plugin/*.vim'
exec 'runtime! '.b.name.'/after/*.vim'
call s:rtp_rm(g:bundle_dir)
endfor
call s:rtp_add_defaults()
endf
" ---------------------------------------------------------------------------
" Create a bundle object from a bundle specification.
"
" name -- the bundle specification as a string
" opts -- the options dictionary from then bundle definition
" return -- an initialized bundle object
" ---------------------------------------------------------------------------
func! vundle#config#init_bundle(name, opts)
if a:name != substitute(a:name, '^\s*\(.\{-}\)\s*$', '\1', '')
echo "Spurious leading and/or trailing whitespace found in plugin spec '" . a:name . "'"
endif
let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')), 'keep')
let b = extend(opts, copy(s:bundle))
let b.rtpath = s:rtpath(opts)
return b
endf
" ---------------------------------------------------------------------------
" Check if the current bundle name has already been used in this running
" instance and show an error to that effect.
"
" bundle -- a bundle object whose name is to be checked
" return -- 0 if the bundle's name has been seen before, 1 otherwise
" ---------------------------------------------------------------------------
funct! s:check_bundle_name(bundle)
if has_key(g:bundle_names, a:bundle.name)
echoerr 'Vundle error: Name collision for Plugin ' . a:bundle.name_spec .
\ '. Plugin ' . g:bundle_names[a:bundle.name] .
\ ' previously used the name "' . a:bundle.name . '"' .
\ '. Skipping Plugin ' . a:bundle.name_spec . '.'
return 0
endif
let g:bundle_names[a:bundle.name] = a:bundle.name_spec
return 1
endf
" ---------------------------------------------------------------------------
" Parse the options which can be supplied with the bundle specification.
" Corresponding documentation: vundle-plugins-configure
"
" opts -- a dictionary with the user supplied options for the bundle
" return -- a dictionary with the user supplied options for the bundle, this
" will be merged with a s:bundle object into one dictionary.
" ---------------------------------------------------------------------------
func! s:parse_options(opts)
" TODO: improve this
if len(a:opts) != 1 | return {} | endif
if type(a:opts[0]) == type({})
return a:opts[0]
else
return {'rev': a:opts[0]}
endif
endf
" ---------------------------------------------------------------------------
" Parse the plugin specification. Corresponding documentation:
" vundle-plugins-uris
"
" arg -- the string supplied to identify the plugin
" return -- a dictionary with the folder name (key 'name') and the uri (key
" 'uri') for cloning the plugin and the original argument (key
" 'name_spec')
" ---------------------------------------------------------------------------
func! s:parse_name(arg)
let arg = a:arg
let git_proto = exists('g:vundle_default_git_proto') ? g:vundle_default_git_proto : 'https'
if arg =~? '^\s*\(gh\|github\):\S\+'
\ || arg =~? '^[a-z0-9][a-z0-9-]*/[^/]\+$'
let uri = git_proto.'://github.com/'.split(arg, ':')[-1]
if uri !~? '\.git$'
let uri .= '.git'
endif
let name = substitute(split(uri,'\/')[-1], '\.git\s*$','','i')
elseif arg =~? '^\s*\(git@\|git://\)\S\+'
\ || arg =~? '\(file\|https\?\)://'
\ || arg =~? '\.git\s*$'
let uri = arg
let name = split( substitute(uri,'/\?\.git\s*$','','i') ,'\/')[-1]
else
let name = arg
let uri = git_proto.'://github.com/vim-scripts/'.name.'.git'
endif
return {'name': name, 'uri': uri, 'name_spec': arg }
endf
" ---------------------------------------------------------------------------
" Modify the runtimepath, after all bundles have been added, so that the
" directories that were in the default runtimepath appear first in the list
" (with their 'after' directories last).
" ---------------------------------------------------------------------------
func! s:rtp_add_defaults()
let current = &rtp
set rtp&vim
let default = &rtp
let &rtp = current
let default_rtp_items = split(default, ',')
if !empty(default_rtp_items)
let first_item = fnameescape(default_rtp_items[0])
exec 'set rtp-=' . first_item
exec 'set rtp^=' . first_item
endif
endf
" ---------------------------------------------------------------------------
" Remove all paths for the plugins which are managed by Vundle from the
" runtimepath.
" ---------------------------------------------------------------------------
func! s:rtp_rm_a()
let paths = map(copy(g:bundles), 'v:val.rtpath')
let prepends = join(paths, ',')
let appends = join(paths, '/after,').'/after'
exec 'set rtp-='.fnameescape(prepends)
exec 'set rtp-='.fnameescape(appends)
endf
" ---------------------------------------------------------------------------
" Add all paths for the plugins which are managed by Vundle to the
" runtimepath.
" ---------------------------------------------------------------------------
func! s:rtp_add_a()
let paths = map(copy(g:bundles), 'v:val.rtpath')
let prepends = join(paths, ',')
let appends = join(paths, '/after,').'/after'
exec 'set rtp^='.fnameescape(prepends)
exec 'set rtp+='.fnameescape(appends)
endf
" ---------------------------------------------------------------------------
" Remove a directory and the corresponding 'after' directory from runtimepath.
"
" dir -- the directory name to be removed as a string. The corresponding
" 'after' directory will also be removed.
" ---------------------------------------------------------------------------
func! s:rtp_rm(dir) abort
exec 'set rtp-='.fnameescape(expand(a:dir, 1))
exec 'set rtp-='.fnameescape(expand(a:dir.'/after', 1))
endf
" ---------------------------------------------------------------------------
" Add a directory and the corresponding 'after' directory to runtimepath.
"
" dir -- the directory name to be added as a string. The corresponding
" 'after' directory will also be added.
" ---------------------------------------------------------------------------
func! s:rtp_add(dir) abort
exec 'set rtp^='.fnameescape(expand(a:dir, 1))
exec 'set rtp+='.fnameescape(expand(a:dir.'/after', 1))
endf
" ---------------------------------------------------------------------------
" Expand and simplify a path.
"
" path -- the path to expand as a string
" return -- the expanded and simplified path
" ---------------------------------------------------------------------------
func! s:expand_path(path) abort
return simplify(expand(a:path, 1))
endf
" ---------------------------------------------------------------------------
" Find the actual path inside a bundle directory to be added to the
" runtimepath. It might be provided by the user with the 'rtp' option.
" Corresponding documentation: vundle-plugins-configure
"
" opts -- a bundle dict
" return -- expanded path to the corresponding plugin directory
" ---------------------------------------------------------------------------
func! s:rtpath(opts)
return has_key(a:opts, 'rtp') ? s:expand_path(a:opts.path().'/'.a:opts.rtp) : a:opts.path()
endf
" ---------------------------------------------------------------------------
" a bundle 'object'
" ---------------------------------------------------------------------------
let s:bundle = {}
" ---------------------------------------------------------------------------
" Return the absolute path to the directory inside the bundle directory
" (prefix) where thr bundle will be cloned.
"
" return -- the target location to clone this bundle to
" ---------------------------------------------------------------------------
func! s:bundle.path()
return s:expand_path(g:bundle_dir.'/'.self.name)
endf
" ---------------------------------------------------------------------------
" Determine if the bundle has the pinned attribute set in the config
"
" return -- 1 if the bundle is pinned, 0 otherwise
" ---------------------------------------------------------------------------
func! s:bundle.is_pinned()
return get(self, 'pinned')
endf
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:

View File

@ -0,0 +1,534 @@
" ---------------------------------------------------------------------------
" Try to clone all new bundles given (or all bundles in g:bundles by default)
" to g:bundle_dir. If a:bang is 1 it will also update all plugins (git pull).
"
" bang -- 1 or 0
" ... -- any number of bundle specifications (separate arguments)
" ---------------------------------------------------------------------------
func! vundle#installer#new(bang, ...) abort
let bundles = (a:1 == '') ?
\ g:bundles :
\ map(copy(a:000), 'vundle#config#bundle(v:val, {})')
let names = vundle#scripts#bundle_names(map(copy(bundles), 'v:val.name_spec'))
call vundle#scripts#view('Installer',['" Installing plugins to '.expand(g:bundle_dir, 1)], names + ['Helptags'])
" This calls 'add' as a normal mode command. This is a buffer local mapping
" defined in vundle#scripts#view(). The mapping will call a buffer local
" command InstallPlugin which in turn will call vundle#installer#run() with
" vundle#installer#install().
call s:process(a:bang, (a:bang ? 'add!' : 'add'))
call vundle#config#require(bundles)
endf
" ---------------------------------------------------------------------------
" Iterate over all lines in a Vundle window and execute the given command for
" every line. Used by the installation and cleaning functions.
"
" bang -- not used (FIXME)
" cmd -- the (normal mode) command to execute for every line as a string
" ---------------------------------------------------------------------------
func! s:process(bang, cmd)
let msg = ''
redraw
sleep 1m
let lines = (getline('.','$')[0:-2])
for line in lines
redraw
exec ':norm '.a:cmd
if 'error' == g:vundle_last_status
let msg = 'With errors; press l to view log'
endif
if 'updated' == g:vundle_last_status && empty(msg)
let msg = 'Plugins updated; press u to view changelog'
endif
" goto next one
exec ':+1'
setl nomodified
endfor
redraw
echo 'Done! '.msg
endf
" ---------------------------------------------------------------------------
" Call another function in the different Vundle windows.
"
" func_name -- the function to call
" name -- the bundle name to call func_name for (string)
" ... -- the argument to be used when calling func_name (only the first
" optional argument will be used)
" return -- the status returned by the call to func_name
" ---------------------------------------------------------------------------
func! vundle#installer#run(func_name, name, ...) abort
let n = a:name
echo 'Processing '.n
call s:sign('active')
sleep 1m
let status = call(a:func_name, a:1)
call s:sign(status)
redraw
if 'new' == status
echo n.' installed'
elseif 'updated' == status
echo n.' updated'
elseif 'todate' == status
echo n.' already installed'
elseif 'deleted' == status
echo n.' deleted'
elseif 'helptags' == status
echo n.' regenerated'
elseif 'pinned' == status
echo n.' pinned'
elseif 'error' == status
echohl Error
echo 'Error processing '.n
echohl None
sleep 1
else
throw 'whoops, unknown status:'.status
endif
let g:vundle_last_status = status
return status
endf
" ---------------------------------------------------------------------------
" Put a sign on the current line, indicating the status of the installation
" step.
"
" status -- string describing the status
" ---------------------------------------------------------------------------
func! s:sign(status)
if (!has('signs'))
return
endif
exe ":sign place ".line('.')." line=".line('.')." name=Vu_". a:status ." buffer=" . bufnr("%")
endf
" ---------------------------------------------------------------------------
" Install a plugin, then add it to the runtimepath and source it.
"
" bang -- 1 or 0, passed directly to vundle#installer#install()
" name -- the name of a bundle (string)
" return -- the return value from vundle#installer#install()
" ---------------------------------------------------------------------------
func! vundle#installer#install_and_require(bang, name) abort
let result = vundle#installer#install(a:bang, a:name)
let b = vundle#config#bundle(a:name, {})
call vundle#installer#helptags([b])
call vundle#config#require([b])
return result
endf
" ---------------------------------------------------------------------------
" Install or update a bundle given by its name.
"
" bang -- 1 or 0, passed directly to s:sync()
" name -- the name of a bundle (string)
" return -- the return value from s:sync()
" ---------------------------------------------------------------------------
func! vundle#installer#install(bang, name) abort
if !isdirectory(g:bundle_dir) | call mkdir(g:bundle_dir, 'p') | endif
let n = substitute(a:name,"['".'"]\+','','g')
let matched = filter(copy(g:bundles), 'v:val.name_spec == n')
if len(matched) > 0
let b = matched[0]
else
let b = vundle#config#init_bundle(a:name, {})
endif
return s:sync(a:bang, b)
endf
" ---------------------------------------------------------------------------
" Call :helptags for all bundles in g:bundles.
"
" return -- 'error' if an error occurred, else return 'helptags'
" ---------------------------------------------------------------------------
func! vundle#installer#docs() abort
let error_count = vundle#installer#helptags(g:bundles)
if error_count > 0
return 'error'
endif
return 'helptags'
endf
" ---------------------------------------------------------------------------
" Call :helptags for a list of bundles.
"
" bundles -- a list of bundle dictionaries for which :helptags should be
" called.
" return -- the number of directories where :helptags failed
" ---------------------------------------------------------------------------
func! vundle#installer#helptags(bundles) abort
let bundle_dirs = map(copy(a:bundles),'v:val.rtpath')
let help_dirs = filter(bundle_dirs, 's:has_doc(v:val)')
call s:log('')
call s:log('Helptags:')
let statuses = map(copy(help_dirs), 's:helptags(v:val)')
let errors = filter(statuses, 'v:val == 0')
call s:log('Helptags: '.len(help_dirs).' plugins processed')
return len(errors)
endf
" ---------------------------------------------------------------------------
" List all installed plugins.
" Corresponding documentation: vundle-plugins-list
"
" bang -- not used
" ---------------------------------------------------------------------------
func! vundle#installer#list(bang) abort
let bundles = vundle#scripts#bundle_names(map(copy(g:bundles), 'v:val.name_spec'))
call vundle#scripts#view('list', ['" My Plugins'], bundles)
redraw
echo len(g:bundles).' plugins configured'
endf
" ---------------------------------------------------------------------------
" List and remove all directories in the bundle directory which are not
" activated (added to the bundle list).
"
" bang -- 0 if the user should be asked to confirm every deletion, 1 if they
" should be removed unconditionally
" ---------------------------------------------------------------------------
func! vundle#installer#clean(bang) abort
let bundle_dirs = map(copy(g:bundles), 'v:val.path()')
let all_dirs = (v:version > 702 || (v:version == 702 && has("patch51")))
\ ? split(globpath(g:bundle_dir, '*', 1), "\n")
\ : split(globpath(g:bundle_dir, '*'), "\n")
let x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)')
if empty(x_dirs)
let headers = ['" All clean!']
let names = []
else
let headers = ['" Removing Plugins:']
let names = vundle#scripts#bundle_names(map(copy(x_dirs), 'fnamemodify(v:val, ":t")'))
end
call vundle#scripts#view('clean', headers, names)
redraw
if (a:bang || empty(names))
call s:process(a:bang, 'D')
else
call inputsave()
let response = input('Continue? [Y/n]: ')
call inputrestore()
if (response =~? 'y' || response == '')
call s:process(a:bang, 'D')
endif
endif
endf
" ---------------------------------------------------------------------------
" Delete to directory for a plugin.
"
" bang -- not used
" dir_name -- the bundle directory to be deleted (as a string)
" return -- 'error' if an error occurred, 'deleted' if the plugin folder was
" successfully deleted
" ---------------------------------------------------------------------------
func! vundle#installer#delete(bang, dir_name) abort
let cmd = ((has('win32') || has('win64')) && empty(matchstr(&shell, 'sh'))) ?
\ 'rmdir /S /Q' :
\ 'rm -rf'
let bundle = vundle#config#init_bundle(a:dir_name, {})
let cmd .= ' '.vundle#installer#shellesc(bundle.path())
let out = s:system(cmd)
call s:log('')
call s:log('Plugin '.a:dir_name)
call s:log(cmd, '$ ')
call s:log(out, '> ')
if 0 != v:shell_error
return 'error'
else
return 'deleted'
endif
endf
" ---------------------------------------------------------------------------
" Check if a bundled plugin has any documentation.
"
" rtp -- a path (string) where the plugin is installed
" return -- 1 if some documentation was found, 0 otherwise
" ---------------------------------------------------------------------------
func! s:has_doc(rtp) abort
return isdirectory(a:rtp.'/doc')
\ && (!filereadable(a:rtp.'/doc/tags') || filewritable(a:rtp.'/doc/tags'))
\ && (v:version > 702 || (v:version == 702 && has("patch51")))
\ ? !(empty(glob(a:rtp.'/doc/*.txt', 1)) && empty(glob(a:rtp.'/doc/*.??x', 1)))
\ : !(empty(glob(a:rtp.'/doc/*.txt')) && empty(glob(a:rtp.'/doc/*.??x')))
endf
" ---------------------------------------------------------------------------
" Update the helptags for a plugin.
"
" rtp -- the path to the plugin's root directory (string)
" return -- 1 if :helptags succeeded, 0 otherwise
" ---------------------------------------------------------------------------
func! s:helptags(rtp) abort
" it is important to keep trailing slash here
let doc_path = resolve(a:rtp . '/doc/')
call s:log(':helptags '.doc_path)
try
execute 'helptags ' . doc_path
catch
call s:log("> Error running :helptags ".doc_path)
return 0
endtry
return 1
endf
" ---------------------------------------------------------------------------
" Get the URL for the remote called 'origin' on the repository that
" corresponds to a given bundle.
"
" bundle -- a bundle object to check the repository for
" return -- the URL for the origin remote (string)
" ---------------------------------------------------------------------------
func! s:get_current_origin_url(bundle) abort
let cmd = 'cd '.vundle#installer#shellesc(a:bundle.path()).' && git config --get remote.origin.url'
let cmd = vundle#installer#shellesc_cd(cmd)
let out = s:strip(s:system(cmd))
return out
endf
" ---------------------------------------------------------------------------
" Get a short sha of the HEAD of the repository for a given bundle
"
" bundle -- a bundle object
" return -- A 15 character log sha for the current HEAD
" ---------------------------------------------------------------------------
func! s:get_current_sha(bundle)
let cmd = 'cd '.vundle#installer#shellesc(a:bundle.path()).' && git rev-parse HEAD'
let cmd = vundle#installer#shellesc_cd(cmd)
let out = s:system(cmd)[0:15]
return out
endf
" ---------------------------------------------------------------------------
" Create the appropriate sync command to run according to the current state of
" the local repository (clone, pull, reset, etc).
"
" In the case of a pull (update), also return the current sha, so that we can
" later check that there has been an upgrade.
"
" bang -- 0 if only new plugins should be installed, 1 if existing plugins
" should be updated
" bundle -- a bundle object to create the sync command for
" return -- A list containing the command to run and the sha for the current
" HEAD
" ---------------------------------------------------------------------------
func! s:make_sync_command(bang, bundle) abort
let git_dir = expand(a:bundle.path().'/.git/', 1)
if isdirectory(git_dir) || filereadable(expand(a:bundle.path().'/.git', 1))
let current_origin_url = s:get_current_origin_url(a:bundle)
if current_origin_url != a:bundle.uri
call s:log('Plugin URI change detected for Plugin ' . a:bundle.name)
call s:log('> Plugin ' . a:bundle.name . ' old URI: ' . current_origin_url)
call s:log('> Plugin ' . a:bundle.name . ' new URI: ' . a:bundle.uri)
" Directory names match but the origin remotes are not the same
let cmd_parts = [
\ 'cd '.vundle#installer#shellesc(a:bundle.path()) ,
\ 'git remote set-url origin ' . vundle#installer#shellesc(a:bundle.uri),
\ 'git fetch',
\ 'git reset --hard origin/HEAD',
\ 'git submodule update --init --recursive',
\ ]
let cmd = join(cmd_parts, ' && ')
let cmd = vundle#installer#shellesc_cd(cmd)
let initial_sha = ''
return [cmd, initial_sha]
endif
if !(a:bang)
" The repo exists, and no !, so leave as it is.
return ['', '']
endif
let cmd_parts = [
\ 'cd '.vundle#installer#shellesc(a:bundle.path()),
\ 'git pull',
\ 'git submodule update --init --recursive',
\ ]
let cmd = join(cmd_parts, ' && ')
let cmd = vundle#installer#shellesc_cd(cmd)
let initial_sha = s:get_current_sha(a:bundle)
else
let cmd = 'git clone --recursive '.vundle#installer#shellesc(a:bundle.uri).' '.vundle#installer#shellesc(a:bundle.path())
let initial_sha = ''
endif
return [cmd, initial_sha]
endf
" ---------------------------------------------------------------------------
" Install or update a given bundle object with git.
"
" bang -- 0 if only new plugins should be installed, 1 if existing plugins
" should be updated
" bundle -- a bundle object (dictionary)
" return -- a string indicating the status of the bundle installation:
" - todate : Nothing was updated or the repository was up to date
" - new : The plugin was newly installed
" - updated : Some changes where pulled via git
" - error : An error occurred in the shell command
" - pinned : The bundle is marked as pinned
" ---------------------------------------------------------------------------
func! s:sync(bang, bundle) abort
" Do not sync if this bundle is pinned
if a:bundle.is_pinned()
return 'pinned'
endif
let [ cmd, initial_sha ] = s:make_sync_command(a:bang, a:bundle)
if empty(cmd)
return 'todate'
endif
let out = s:system(cmd)
call s:log('')
call s:log('Plugin '.a:bundle.name_spec)
call s:log(cmd, '$ ')
call s:log(out, '> ')
if 0 != v:shell_error
return 'error'
end
if empty(initial_sha)
return 'new'
endif
let updated_sha = s:get_current_sha(a:bundle)
if initial_sha == updated_sha
return 'todate'
endif
call add(g:updated_bundles, [initial_sha, updated_sha, a:bundle])
return 'updated'
endf
" ---------------------------------------------------------------------------
" Escape special characters in a string to be able to use it as a shell
" command with system().
"
" cmd -- the string holding the shell command
" return -- a string with the relevant characters escaped
" ---------------------------------------------------------------------------
func! vundle#installer#shellesc(cmd) abort
if ((has('win32') || has('win64')) && empty(matchstr(&shell, 'sh')))
return '"' . substitute(a:cmd, '"', '\\"', 'g') . '"'
endif
return shellescape(a:cmd)
endf
" ---------------------------------------------------------------------------
" Fix a cd shell command to be used on Windows.
"
" cmd -- the command to be fixed (string)
" return -- the fixed command (string)
" ---------------------------------------------------------------------------
func! vundle#installer#shellesc_cd(cmd) abort
if ((has('win32') || has('win64')) && empty(matchstr(&shell, 'sh')))
let cmd = substitute(a:cmd, '^cd ','cd /d ','') " add /d switch to change drives
return cmd
else
return a:cmd
endif
endf
" ---------------------------------------------------------------------------
" Make a system call. This can be used to change the way system calls
" are made during developing, without searching the whole code base for
" actual system() calls.
"
" cmd -- the command passed to system() (string)
" return -- the return value from system()
" ---------------------------------------------------------------------------
func! s:system(cmd) abort
return system(a:cmd)
endf
" ---------------------------------------------------------------------------
" Add a log message to Vundle's internal logging variable.
"
" str -- the log message (string)
" prefix -- optional prefix for multi-line entries (string)
" return -- a:str
" ---------------------------------------------------------------------------
func! s:log(str, ...) abort
let prefix = a:0 > 0 ? a:1 : ''
let fmt = '%Y-%m-%d %H:%M:%S'
let lines = split(a:str, '\n', 1)
let time = strftime(fmt)
for line in lines
call add(g:vundle_log, '['. time .'] '. prefix . line)
endfor
return a:str
endf
" ---------------------------------------------------------------------------
" Remove leading and trailing whitespace from a string
"
" str -- The string to rid of trailing and leading spaces
" return -- A string stripped of side spaces
" ---------------------------------------------------------------------------
func! s:strip(str)
return substitute(a:str, '\%^\_s*\(.\{-}\)\_s*\%$', '\1', '')
endf
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:

View File

@ -0,0 +1,257 @@
" ---------------------------------------------------------------------------
" Search the database from vim-script.org for a matching plugin. If no
" argument is given, list all plugins. This function is used by the :Plugins
" and :PluginSearch commands.
"
" bang -- if 1 refresh the script name cache, if 0 don't
" ... -- a plugin name to search for
" ---------------------------------------------------------------------------
func! vundle#scripts#all(bang, ...)
let b:match = ''
let info = ['"Keymap: i - Install plugin; c - Cleanup; s - Search; R - Reload list']
let matches = s:load_scripts(a:bang)
if !empty(a:1)
let matches = filter(matches, 'v:val =~? "'.escape(a:1,'"').'"')
let info += ['"Search results for: '.a:1]
" TODO: highlight matches
let b:match = a:1
endif
call vundle#scripts#view('search',info, vundle#scripts#bundle_names(reverse(matches)))
redraw
echo len(matches).' plugins found'
endf
" ---------------------------------------------------------------------------
" Repeat the search for bundles.
" ---------------------------------------------------------------------------
func! vundle#scripts#reload() abort
silent exec ':PluginSearch! '.(exists('b:match') ? b:match : '')
redraw
endf
" ---------------------------------------------------------------------------
" Complete names for bundles in the command line.
"
" a, c, d -- see :h command-completion-custom
" return -- all valid plugin names from vim-scripts.org as completion
" candidates, see also :h command-completion-custom
" ---------------------------------------------------------------------------
func! vundle#scripts#complete(a,c,d)
return join(s:load_scripts(0),"\n")
endf
" ---------------------------------------------------------------------------
" View the logfile after an update or installation.
" ---------------------------------------------------------------------------
func! s:view_log()
if !exists('g:vundle_log_file')
let g:vundle_log_file = tempname()
endif
call writefile(g:vundle_log, g:vundle_log_file)
execute 'silent pedit ' . g:vundle_log_file
wincmd P | wincmd H
endf
" ---------------------------------------------------------------------------
" Parse the output from git log after an update to create a change log for the
" user.
" ---------------------------------------------------------------------------
func! s:create_changelog() abort
for bundle_data in g:updated_bundles
let initial_sha = bundle_data[0]
let updated_sha = bundle_data[1]
let bundle = bundle_data[2]
let cmd = 'cd '.vundle#installer#shellesc(bundle.path()).
\ ' && git log --pretty=format:"%s %an, %ar" --graph '.
\ initial_sha.'..'.updated_sha
let cmd = vundle#installer#shellesc_cd(cmd)
let updates = system(cmd)
call add(g:vundle_changelog, '')
call add(g:vundle_changelog, 'Updated Plugin: '.bundle.name)
if bundle.uri =~ "https://github.com"
call add(g:vundle_changelog, 'Compare at: '.bundle.uri[0:-5].'/compare/'.initial_sha.'...'.updated_sha)
endif
for update in split(updates, '\n')
let update = substitute(update, '\s\+$', '', '')
call add(g:vundle_changelog, ' '.update)
endfor
endfor
endf
" ---------------------------------------------------------------------------
" View the change log after an update or installation.
" ---------------------------------------------------------------------------
func! s:view_changelog()
call s:create_changelog()
if !exists('g:vundle_changelog_file')
let g:vundle_changelog_file = tempname()
endif
call writefile(g:vundle_changelog, g:vundle_changelog_file)
execute 'silent pedit ' . g:vundle_changelog_file
wincmd P | wincmd H
endf
" ---------------------------------------------------------------------------
" Create a list of 'Plugin ...' lines from a list of bundle names.
"
" names -- a list of names (strings) of plugins
" return -- a list of 'Plugin ...' lines suitable to be written to a buffer
" ---------------------------------------------------------------------------
func! vundle#scripts#bundle_names(names)
return map(copy(a:names), ' printf("Plugin ' ."'%s'".'", v:val) ')
endf
" ---------------------------------------------------------------------------
" Open a buffer to display information to the user. Several special commands
" are defined in the new buffer.
"
" title -- a title for the new buffer
" headers -- a list of header lines to be displayed at the top of the buffer
" results -- the main information to be displayed in the buffer (list of
" strings)
" ---------------------------------------------------------------------------
func! vundle#scripts#view(title, headers, results)
if exists('g:vundle_view') && bufloaded(g:vundle_view)
exec g:vundle_view.'bd!'
endif
exec 'silent pedit [Vundle] '.a:title
wincmd P | wincmd H
let g:vundle_view = bufnr('%')
"
" make buffer modifiable
" to append without errors
set modifiable
call append(0, a:headers + a:results)
setl buftype=nofile
setl noswapfile
setl cursorline
setl nonu ro noma
if (exists('&relativenumber')) | setl norelativenumber | endif
setl ft=vundle
setl syntax=vim
syn keyword vimCommand Plugin
syn keyword vimCommand Bundle
syn keyword vimCommand Helptags
com! -buffer -bang -nargs=1 DeletePlugin
\ call vundle#installer#run('vundle#installer#delete', split(<q-args>,',')[0], ['!' == '<bang>', <args>])
com! -buffer -bang -nargs=? InstallAndRequirePlugin
\ call vundle#installer#run('vundle#installer#install_and_require', split(<q-args>,',')[0], ['!' == '<bang>', <q-args>])
com! -buffer -bang -nargs=? InstallPlugin
\ call vundle#installer#run('vundle#installer#install', split(<q-args>,',')[0], ['!' == '<bang>', <q-args>])
com! -buffer -bang -nargs=0 InstallHelptags
\ call vundle#installer#run('vundle#installer#docs', 'helptags', [])
com! -buffer -nargs=0 VundleLog call s:view_log()
com! -buffer -nargs=0 VundleChangelog call s:view_changelog()
nnoremap <buffer> q :silent bd!<CR>
nnoremap <buffer> D :exec 'Delete'.getline('.')<CR>
nnoremap <buffer> add :exec 'Install'.getline('.')<CR>
nnoremap <buffer> add! :exec 'Install'.substitute(getline('.'), '^Plugin ', 'Plugin! ', '')<CR>
nnoremap <buffer> i :exec 'InstallAndRequire'.getline('.')<CR>
nnoremap <buffer> I :exec 'InstallAndRequire'.substitute(getline('.'), '^Plugin ', 'Plugin! ', '')<CR>
nnoremap <buffer> l :VundleLog<CR>
nnoremap <buffer> u :VundleChangelog<CR>
nnoremap <buffer> h :h vundle<CR>
nnoremap <buffer> ? :norm h<CR>
nnoremap <buffer> c :PluginClean<CR>
nnoremap <buffer> C :PluginClean!<CR>
nnoremap <buffer> s :PluginSearch
nnoremap <buffer> R :call vundle#scripts#reload()<CR>
" goto first line after headers
exec ':'.(len(a:headers) + 1)
endf
" ---------------------------------------------------------------------------
" Load the plugin database from vim-scripts.org .
"
" to -- the filename (string) to save the database to
" return -- 0 on success, 1 if an error occurred
" ---------------------------------------------------------------------------
func! s:fetch_scripts(to)
let scripts_dir = fnamemodify(expand(a:to, 1), ":h")
if !isdirectory(scripts_dir)
call mkdir(scripts_dir, "p")
endif
let l:vim_scripts_json = 'http://vim-scripts.org/api/scripts.json'
if executable("curl")
let cmd = 'curl --fail -s -o '.vundle#installer#shellesc(a:to).' '.l:vim_scripts_json
elseif executable("wget")
let temp = vundle#installer#shellesc(tempname())
let cmd = 'wget -q -O '.temp.' '.l:vim_scripts_json. ' && mv -f '.temp.' '.vundle#installer#shellesc(a:to)
if (has('win32') || has('win64'))
let cmd = substitute(cmd, 'mv -f ', 'move /Y ', '') " change force flag
let cmd = vundle#installer#shellesc(cmd)
end
else
echoerr 'Error curl or wget is not available!'
return 1
endif
call system(cmd)
if (0 != v:shell_error)
echoerr 'Error fetching scripts!'
return v:shell_error
endif
return 0
endf
" ---------------------------------------------------------------------------
" Load the plugin database and return a list of all plugins.
"
" bang -- if 1 download the redatabase, else only download if it is not
" readable on disk (i.e. does not exist)
" return -- a list of strings, these are the names (valid bundle
" specifications) of all plugins from vim-scripts.org
" ---------------------------------------------------------------------------
func! s:load_scripts(bang)
let f = expand(g:bundle_dir.'/.vundle/script-names.vim-scripts.org.json', 1)
if a:bang || !filereadable(f)
if 0 != s:fetch_scripts(f)
return []
end
endif
return eval(readfile(f, 'b')[0])
endf
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:

View File

@ -0,0 +1,22 @@
Change Log
==========
F = Feature, B = Bug Fix, D = Doc Change
### Version 0.10.2
- B: #430 Put user script directories before system directories in rtp
- B: #455 Rename functions that start with `g:` + lowercase letter (Vim patch 7.4.264)
### Version 0.10.1
- B: #451 Escape spaces when handling rtp directories
### Version 0.10
- F: #415 Support plugin pinning (for non-git repos & preventing updates)
- F: #440 Detect plugin name collisions
- F: #418 Deferred rtp manipulation (speeds up start)
- B: #418 Leave default rtp directories (i.e. ~/.vim) where they should be
- B: #429 Fix newline character in log
- B: #440 Detect changed remotes & update repos
- D: #435 Image update in README.md
- D: #419 Add function documentation
- D: #436 Rename vundle to Vundle.vim, add modelines, quickstart update

View File

@ -0,0 +1,38 @@
:Bundle vundle.txt /*:Bundle*
:BundleClean! vundle.txt /*:BundleClean!*
:BundleInstall! vundle.txt /*:BundleInstall!*
:BundleList vundle.txt /*:BundleList*
:BundleSearch vundle.txt /*:BundleSearch*
:BundleUpdate vundle.txt /*:BundleUpdate*
:Plugin vundle.txt /*:Plugin*
:PluginClean vundle.txt /*:PluginClean*
:PluginClean! vundle.txt /*:PluginClean!*
:PluginInstall vundle.txt /*:PluginInstall*
:PluginInstall! vundle.txt /*:PluginInstall!*
:PluginList vundle.txt /*:PluginList*
:PluginSearch vundle.txt /*:PluginSearch*
:PluginSearch! vundle.txt /*:PluginSearch!*
:PluginUpdate vundle.txt /*:PluginUpdate*
:VundleClean! vundle.txt /*:VundleClean!*
:VundleInstall! vundle.txt /*:VundleInstall!*
:VundleList vundle.txt /*:VundleList*
:VundleSearch vundle.txt /*:VundleSearch*
:VundleUpdate vundle.txt /*:VundleUpdate*
vundle vundle.txt /*vundle*
vundle-about vundle.txt /*vundle-about*
vundle-faq vundle.txt /*vundle-faq*
vundle-interactive vundle.txt /*vundle-interactive*
vundle-interface-change vundle.txt /*vundle-interface-change*
vundle-keymappings vundle.txt /*vundle-keymappings*
vundle-options vundle.txt /*vundle-options*
vundle-plugins vundle.txt /*vundle-plugins*
vundle-plugins-cleanup vundle.txt /*vundle-plugins-cleanup*
vundle-plugins-configure vundle.txt /*vundle-plugins-configure*
vundle-plugins-install vundle.txt /*vundle-plugins-install*
vundle-plugins-list vundle.txt /*vundle-plugins-list*
vundle-plugins-search vundle.txt /*vundle-plugins-search*
vundle-plugins-update vundle.txt /*vundle-plugins-update*
vundle-plugins-uris vundle.txt /*vundle-plugins-uris*
vundle-quickstart vundle.txt /*vundle-quickstart*
vundle-windows vundle.txt /*vundle-windows*
vundle.txt vundle.txt /*vundle.txt*

View File

@ -0,0 +1,397 @@
*vundle.txt* Vundle, a plug-in manager for Vim. *vundle*
VUNDLE MANUAL
1. About Vundle |vundle-about|
2. Quick Start |vundle-quickstart|
3. Plugins |vundle-plugins|
3.1. Configuring Plugins |vundle-plugins-configure|
3.2. Supported URIs |vundle-plugins-uris|
3.3. Installing Plugins |vundle-plugins-install|
3.4. Updating Plugins |vundle-plugins-update|
3.5. Searching Plugins |vundle-plugins-search|
3.6. Listing Plugins |vundle-plugins-list|
3.7. Cleaning Up |vundle-plugins-cleanup|
4. Interactive Mode |vundle-interactive|
5. Key Mappings |vundle-keymappings|
6. Options |vundle-options|
7. Plugin Interface Change |vundle-interface-change|
=============================================================================
1. ABOUT VUNDLE ~
*vundle-about*
Vundle is short for Vim bundle and is a Vim plugin manager.
Vundle allows you to...
- keep track of and configure your scripts right in the `.vimrc`
- install configured scripts (a.k.a. bundle)
- update configured scripts
- search by name all available Vim scripts
- clean unused scripts up
- run the above actions in a single keypress with interactive mode
Vundle automatically...
- manages the runtime path of your installed scripts
- regenerates help tags after installing and updating
Vundle's search uses http://vim-scripts.org to provide a list of all
available Vim scripts.
Vundle is undergoing an interface change, see |vundle-interface-change| for
more information.
=============================================================================
2. QUICK START ~
*vundle-quickstart*
1. Introduction:
Installation requires `Git` and triggers git clone for each configured
repository to `~/.vim/bundle/` by default. Curl is required for search.
*vundle-windows*
If you are using Windows, see instructions on the Wiki
https://github.com/gmarik/Vundle.vim/wiki/Vundle-for-Windows.
*vundle-faq*
If you run into any issues, please consult the FAQ at
https://github.com/gmarik/Vundle.vim/wiki
2. Setup Vundle:
>
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
<
3. Configure bundles:
Put this at the top of your `.vimrc` to use Vundle. Remove bundles you
don't need, they are for illustration purposes.
>
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
Plugin 'user/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - list configured plugins
" :PluginInstall(!) - install (update) plugins
" :PluginSearch(!) foo - search (or refresh cache first) for foo
" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
4. Install configured bundles:
Launch vim and run
>
:PluginInstall
<
To install from command line:
>
vim +PluginInstall +qall
=============================================================================
3. PLUGINS ~
*vundle-plugins*
3.1 CONFIGURING PLUGINS ~
*vundle-plugins-configure* *:Plugin*
Vundle tracks what plugins you want configured by the `Plugin` commands in your
`.vimrc`. Each `Plugin` command tells Vundle to activate the script on startup
adding it to your |runtimepath|. Commenting out or removing the line will
disable the `Plugin`.
Each `Plugin` command takes a URI pointing to the script. No comments should
follow on the same line as the command. Example:
>
Plugin 'git_URI'
The `Plugin` command can optionally take a second argument after the URI. It
has to be a dictionary, separated from the URI by a comma. Each key-value pair
in the dictionary is a configuration option.
The following per-script configuration options are available.
The 'rtp' option
----------------
Specifies a directory inside the repository (relative path from the root of
the repository) where the vim plugin resides. It determines the path that will
be added to the |runtimepath|.
For example:
>
Plugin 'git_URI', {'rtp': 'some/subdir/'}
This can be used with git repositories that put the vim plugin inside a
subdirectory.
The 'name' option
-----------------
The name of the directory that will hold the local clone of the configured
script.
For example:
>
Plugin 'git_URI', {'name': 'newPluginName'}
This can be used to prevent name collisions between plugins that Vundle would
otherwise try to clone into the same directory. It also provides an additional
level of customisation.
The 'pinned' option
-------------------
A flag that, when set to a value of 1, tells Vundle not to perform any git
operations on the plugin, while still adding the existing plugin under the
`bundles` directories to the |runtimepath|.
For example:
>
Plugin 'mylocalplugin', {'pinned': 1}
This allows the users to include, with Vundle, plugins tracked with version
control systems other than git, but the user is responsible for cloning and
keeping up to date. It also allows the users to stay in the current version of
a plugin that might have previously been updated by Vundle.
Please note that the URI will be treated the same as for any other plugins, so
only the last part of it will be added to the |runtimepath|. The user is
advised to use this flag only with single word URIs to avoid confusion.
3.2 SUPPORTED URIS ~
*vundle-plugins-uris*
`Vundle` integrates very well with both GitHub and vim-scripts.org
(http://vim-scripts.org/vim/scripts.html) allowing short URIs. It also allows
the use of any URI `git` recognizes. In all of the following cases (except
local) the 'https' protocol is used, see Vundle's options to override this.
More information on `git`'s protocols can be found at:
http://git-scm.com/book/ch4-1.html
GitHub
------
GitHub is used when a user/repo is passed to `Plugin`.
>
Plugin 'gmarik/Vundle.vim' => https://github.com/gmarik/Vundle.vim
Vim Scripts
-----------
Any single word without a slash '/' is assumed to be from Vim Scripts.
>
Plugin 'ctrlp.vim' => https://github.com/vim-scripts/ctrlp.vim
Other Git URIs
--------------
No modification is performed on valid URIs that point outside the above
URLs.
>
Plugin 'git://git.wincent.com/command-t.git'
Local Plugins
-------------
The git protocol supports local installation using the 'file://' protocol.
This is handy when developing plugins locally. Follow the protocol with an
absolute path to the script directory.
>
Plugin 'file:///path/from/root/to/plugin'
3.3 INSTALLING PLUGINS ~
*vundle-plugins-install* *:PluginInstall*
>
:PluginInstall
Will install all plugins configured in your `.vimrc`. Newly installed
plugins will be automatically enabled. Some plugins may require extra steps
such as compilation or external programs, refer to their documentation.
PluginInstall allows installation of plugins by name:
>
:PluginInstall unite.vim
Installs and activates unite.vim. You can use Tab to auto-complete known
script names. Note that the installation just described isn't permanent. To
finish, you must put `Plugin 'unite.vim'` at the appropriate place in your
`.vimrc` to tell Vundle to load the plugin at startup.
After installing plugins press 'l' (lowercase 'L') to see the log of commands
if any errors occurred.
3.4 UPDATING PLUGINS ~
*vundle-plugins-update* *:PluginUpdate* *:PluginInstall!*
>
:PluginInstall! " NOTE: bang(!)
or >
:PluginUpdate
Installs or updates the configured plugins. Press 'u' after updates complete
to see the change log of all updated bundles. Press 'l' (lowercase 'L') to
see the log of commands if any errors occurred.
3.5 SEARCHING PLUGINS ~
*vundle-plugins-search* *:PluginSearch*
>
:PluginSearch
Search requires that `curl` be available on the system. The command searches
Vim Scripts (http://vim-scripts.org/vim/scripts.html) for matching
plugins. Results display in a new split window. For example:
>
PluginSearch foo
displays:
>
"Search results for: foo
Plugin 'MarkdownFootnotes'
Plugin 'VimFootnotes'
Plugin 'foo.vim'
<
*:PluginSearch!*
Alternatively, you can refresh the script list before searching by adding a
bang to the command.
>
:PluginSearch! foo
If the command is run without argument:
>
:PluginSearch!
it will display all known plugins in the new split.
3.6 LISTING BUNDLES ~
*vundle-plugins-list* *:PluginList*
>
:PluginList
Displays a list of installed bundles.
3.7 CLEANING UP ~
*vundle-plugins-cleanup* *:PluginClean*
>
:PluginClean
Requests confirmation for the removal of all plugins no longered configured
in your `.vimrc` but present in your bundle installation directory
(default: `.vim/bundle/`).
*:PluginClean!*
>
:PluginClean!
Automatically confirm removal of unused bundles.
=============================================================================
4. INTERACTIVE MODE ~
*vundle-interactive*
Vundle provides a simple interactive mode to help you explore new plugins
easily. Interactive mode is available after any command that lists `Plugins`
such as PluginSearch, PluginList or Plugins. For instance:
>
:PluginSearch! unite
Searches for plugins matching 'unite' and yields a split window with:
>
"Keymap: i - Install bundle; c - Cleanup; s - Search; R - Reload list
"Search results for: unite
Plugin 'unite-scriptenames'
Plugin 'unite.vim'
Plugin 'unite-yarm'
Plugin 'unite-gem'
Plugin 'unite-locate'
Plugin 'unite-font'
Plugin 'unite-colorscheme'
To install a bundle, move your cursor to the Plugin of interest and then
select a command. To install 'unite.vim' put your cursor on the line and
then push `i`. For a more complete list see |vundle-keymappings|. After
unite.vim is installed the `:Unite file` command should be available.
Note: Interactive installation doesn't update your `.vimrc`.
=============================================================================
5. KEY MAPPINGS ~
*vundle-keymappings*
KEY | DESCRIPTION
----|-------------------------- >
i | run :PluginInstall with name taken from line cursor is positioned on
I | same as i, but runs :PluginInstall! to update bundle
D | delete selected bundle (be careful not to remove local modifications)
c | run :PluginClean
s | run :PluginSearch
R | fetch fresh script list from server
=============================================================================
6. OPTIONS ~
*vundle-options*
>
let g:vundle_default_git_proto = 'git'
<
This option makes Vundle use `git` instead of `https` when building
absolute URIs. For example:
>
Plugin 'sjl/gundo.vim' -> git@github.com:sjl/gundo.git
=============================================================================
7. VUNDLE INTERFACE CHANGE ~
*vundle-interface-change* *:Bundle* *:BundleInstall!*
*:BundleUpdate* *:BundleSearch* *:BundleList* *:BundleClean!*
*:VundleInstall!* *:VundleUpdate* *:VundleSearch*
*:VundleList* *:VundleClean!*
In order to bring in new changes, Vundle is adopting a new interface.
Going forward we will support primarily the Plugin namespace, additionally
for convenience we will also alias some commands to the Vundle namespace.
The following table summarizes the interface changes.
Deprecated Names | New Names
-----------------------------
Bundle | Plugin
BundleInstall(!) | PluginInstall(!), VundleInstall(!)
BundleUpdate | PluginUpdate, VundleUpdate
BundleSearch(!) | PluginSearch(!), VundleSearch(!)
BundleClean | PluginClean(!), VundleClean(!)
BundleList | PluginList
Note: The Bundle commands will be deprecated. You may continue using them,
but they may not get all future updates. For instance, we have enabled
comments on Plugin lines but not Bundle, since it requires a change in
command declaration.
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 ft=help norl:

View File

@ -0,0 +1,20 @@
-module(mmc_logmon_sup).
-behaviour(supervisor).
-export([init/1]).
init(_) ->
{ok, {
{one_for_one, 5, 1},
[
{listener,
{aaa, start_link, []},
permanent, 100, worker,
[aaa]
},
{server,
{bbb, start_link, []},
permanent, 100, worker,
[bbb]
}
]
}}.

View File

@ -0,0 +1,8 @@
set nocompatible
syntax on
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#rc()
Bundle 'gmarik/Vundle.vim'
filetype plugin indent on

View File

@ -0,0 +1,81 @@
" vim -u test/vimrc
set nocompatible
set nowrap
let bundle_dir = '/tmp/vundle-test/bundles/'
" let src = 'http://github.com/gmarik/vundle.git'
" Vundle Options
" let g:vundle_default_git_proto = 'git'
silent execute '!mkdir -p '.bundle_dir
silent execute '!ln -f -s ~/.vim/bundle/Vundle.vim '.bundle_dir
filetype off
syntax on
runtime macros/matchit.vim
" This test should be executed in "test" directory
exec 'set rtp^='.bundle_dir.'Vundle.vim/'
call vundle#rc(bundle_dir)
Plugin 'molokai' " vim-scripts name
" github username with dashes
Bundle 'vim-scripts/ragtag.vim'
" original repo
Bundle 'altercation/vim-colors-solarized'
" with extension
Bundle 'nelstrom/vim-mac-classic-theme.git'
"
" invalid uri
"Bundle 'nonexistinguser/yupppierepo.git'
" full uri
Bundle 'https://github.com/vim-scripts/vim-game-of-life'
" full uri
Bundle 'git@github.com:gmarik/ingretu.git'
" short uri
Bundle 'gh:gmarik/snipmate.vim.git'
Bundle 'github:mattn/gist-vim.git'
" local uri stuff
Bundle '~/Dropbox/.gitrepos/utilz.vim.git'
" Bundle 'file://Dropbox/.gitrepos/utilz.vim.git'
" with options
Bundle 'rstacruz/sparkup.git', {'rtp': 'vim/'}
Bundle 'matchit.zip', {'name': 'matchit'}
" Camel case
Bundle 'vim-scripts/RubySinatra'
" syntax issue #203
Bundle 'jimenezrick/vimerl'
" Static bundle: Same name as a valid vim-scripts bundle
Bundle 'latte', {'pinned' : 1}
if !isdirectory(expand(bundle_dir) . '/latte')
call mkdir(expand(bundle_dir) . '/latte', 'p')
endif
filetype plugin indent on " Automatically detect file types.
set wildignore+=doc " should not break helptags
set wildignore+=.git " should not break clone
set wildignore+=.git/* " should not break clone
set wildignore+=*/.git/*
" TODO: helptags fails with this
" set wildignore+=doc/* " should not break clone
" set wildignore+=*/doc/*
au VimEnter * BundleInstall
" e test/files/erlang.erl
" vim: set expandtab sts=2 ts=2 sw=2 tw=78:

View File

@ -0,0 +1,13 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=2727
a plugin to format your javascript souce code
A js version can be found at:
http://jsbeautifier.org/
I just translated it into vimscript, it works at a low performance:)
usage:
<leader>ff
or
bind the g:Jsbeautify() function to any short key you like

View File

@ -0,0 +1,623 @@
if &cp || exists("loaded_jsbeautify")
finish
endif
let loaded_jsbeautify = 3
function! s:trim_output()
while len(s:output) > 0 && (s:output[len(s:output)-1] == " " || s:output[len(s:output)-1] == s:indent_string)
call remove(s:output, -1)
endwhile
endfunction
function! s:print_newline(ignore_repeated)
let s:if_line_flag = 0
call s:trim_output()
if len(s:output)==0
return
endif
if s:output[len(s:output)-1] != "\n" || !a:ignore_repeated
call add(s:output, "\n")
endif
let index = 0
while index < s:indent_level
call add(s:output, s:indent_string)
let index += 1
endwhile
endfunction
function! s:print_space()
let last_output = " "
if len(s:output) > 0
let last_output = s:output[len(s:output) - 1]
endif
if last_output != " " && last_output != "\n" && last_output != s:indent_string
call add(s:output, " ")
endif
endfunction
function! s:print_token()
call add(s:output, s:token_text)
endfunctio
function! s:indent()
let s:indent_level += 1
endfunction
function! s:unindent()
if s:indent_level
let s:indent_level -= 1
endif
endfunction
function! s:remove_indent()
if len(s:output)>0 && s:output[len(s:output) -1] == s:indent_string
call remove(s:output, -1)
endif
endfunction
function! s:set_mode(mode)
call add(s:modes, s:current_mode)
let s:current_mode = a:mode
endfunction
function! s:restore_mode()
if s:current_mode == "DO_BLOCK"
let s:do_block_just_closed = 1
else
let s:do_block_just_closed = 0
endif
let s:current_mode = remove(s:modes, -1)
endfunction
function! s:in_array(what, arr)
return index(a:arr, a:what) != -1
endfunction
function! s:get_next_token()
let n_newlines = 0
if s:parser_pos >= len(s:input)
return ["", "TK_EOF"]
endif
let c = s:input[s:parser_pos]
let s:parser_pos += 1
while s:in_array(c, s:whitespace)
if s:parser_pos >= len(s:input)
return ["", "TK_EOF"]
endif
if c == "\n"
let n_newlines += 1
endif
let c = s:input[s:parser_pos]
let s:parser_pos += 1
endwhile
let wanted_newline = 0
if s:opt_preserve_newlines
if n_newlines > 1
for i in [0, 1]
call s:print_newline(i==0)
endfor
endif
let wanted_newline = n_newlines == 1
endif
if s:in_array(c, s:wordchar)
if s:parser_pos < len(s:input)
while s:in_array(s:input[s:parser_pos], s:wordchar)
let c .= s:input[s:parser_pos]
let s:parser_pos += 1
if s:parser_pos == len(s:input)
break
endif
endwhile
endif
"if s:parser_pos != len(s:input) && c =~ /^[0-9]+[Ee]$/ && (s:input[s:parser_pos] == "-" || s:input[s:parser_pos] == "+")
"let sign = s:input[s:parser_pos]
"let s:parser_pos += 1
"let t = get_next_token(s:parser_pos)
"let c .= sign . t[0]
"return [c, "TK_WORD"]
" endif
if c == "in"
return [c, "TK_OPERATOR"]
endif
if wanted_newline && s:last_type != "TK_OPERATOR" && !s:if_line_flag
call s:print_newline(1)
endif
return [c, "TK_WORD"]
endif
if c == "(" || c == "["
return [c, "TK_START_EXPR"]
endif
if c == ")" || c == "]"
return [c, "TK_END_EXPR"]
endif
if c == "{"
return [c, "TK_START_BLOCK"]
endif
if c == "}"
return [c, "TK_END_BLOCK"]
endif
if c == ";"
return [c, "TK_SEMICOLON"]
endif
if c == "/"
let comment = ""
if s:input[s:parser_pos] == "*"
let s:parser_pos += 1
if s:parser_pos < len(s:input)
while !(s:input[s:parser_pos] == "*" && s:parser_pos + 1 < len(s:input) && s:input[s:parser_pos + 1] == "/" && s:parser_pos < len(s:input))
let comment .= s:input[s:parser_pos]
let s:parser_pos += 1
if s:parser_pos >= len(s:input)
break
endif
endwhile
endif
let s:parser_pos += 2
return ['/*' . comment . '*/', 'TK_BLOCK_COMMENT']
endif
" peek for comment // ...
if s:input[s:parser_pos] == "/"
let comment = c
while s:input[s:parser_pos] != "\r" && s:input[s:parser_pos] != "\n"
let comment .= s:input[s:parser_pos]
let s:parser_pos += 1
if s:parser_pos >= len(s:input)
break
endif
endwhile
let s:parser_pos += 1
if wanted_newline
call s:print_newline(1)
endif
return [comment, "TK_COMMENT"]
endif
endif
if c == "'" || c =='"' || (c == "/" && ((s:last_type == "TK_WORD" && s:last_text == "return") || (s:last_type == "TK_START_EXPR" || s:last_type == "TK_START_BLOCK" || s:last_type == "TK_END_BLOCK" || s:last_type == "TK_OPERATOR" || s:last_type == "TK_EOF" || s:last_type == "TK_SEMICOLON")))
let sep = c
let esc = 0
let resulting_string = c
if s:parser_pos < len(s:input)
while esc || s:input[s:parser_pos] != sep
let resulting_string .= s:input[s:parser_pos]
if !esc
let esc = s:input[s:parser_pos] == "\\"
else
let esc = 0
endif
let s:parser_pos += 1
if s:parser_pos >= len(s:input)
return [resulting_string, "TK_STRING"]
endif
endwhile
endif
let s:parser_pos += 1
let resulting_string .= sep
if sep == "/"
while s:parser_pos < len(s:input) && s:in_array(s:input[s:parser_pos], s:wordchar)
let resulting_string .= s:input[s:parser_pos]
let s:parser_pos += 1
endwhile
endif
return [resulting_string, "TK_STRING"]
endif
if c == "#"
let sharp = "#"
if s:parser_pos < len(s:input) && s:in_array(s:input[s:parser_pos], s:digits)
let c = s:input[s:parser_pos]
let sharp .= c
let s:parser_pos += 1
while s:parser_pos < len(s:input) && c != "#" && c !="="
let c = s:input[s:parser_pos]
let sharp .= c
let s:parser_pos += 1
endwhile
if c == "#"
return [sharp, "TK_WORD"]
else
return [sharp, "TK_OPERATOR"]
endif
endif
endif
if c == "<" && s:input[s:parser_pos-1 : s:parser_pos+3] == "<!--"
let s:parser_pos += 3
return ["<!--", "TK_COMMENT"]
endif
if c == "-" && s:input[s:parser_pos-1 : s:parser_pos+2] == "-->"
let s:parser_pos += 2
if wanted_newline
call s:print_newline(1)
endif
return ["-->", "TK_COMMENT"]
endif
if s:in_array(c, s:punct)
while s:parser_pos < len(s:input) && s:in_array(c . s:input[s:parser_pos], s:punct)
let c .= s:input[s:parser_pos]
let s:parser_pos += 1
if s:parser_pos >= len(s:input)
break
endif
endwhile
return [c, "TK_OPERATOR"]
endif
return [c, "TK_UNKNOWN"]
endif
endfunction
function! s:is_js()
return expand("%:e") == "js"
endfunction
"function! g:Jsbeautify(js_source_text, options)
function! g:Jsbeautify()
if !s:is_js()
echo "Not a JS file."
return
endif
"let a:options = {}
let s:opt_indent_size = 1
let s:opt_indent_char = "\t"
let s:opt_preserve_newlines = 1
let s:opt_indent_level = 0
let s:if_line_flag = 0
"--------------------------------
let s:indent_string = ""
while s:opt_indent_size > 0
let s:indent_string .= s:opt_indent_char
let s:opt_indent_size -= 1
endwhile
let s:indent_level = s:opt_indent_level
let lines = getline(1, "$")
let s:input = join(lines, "\n")
"let s:input = a:js_source_text
let s:last_word = "" "last 'TK_WORD' passed
let s:last_type = "TK_START_EXPR" "last token type
let s:last_text = "" "last token text
let s:output = []
let s:do_block_just_closed = 0
let s:var_line = 0
let s:var_line_tainted = 0
let s:whitespace = ["\n", "\r", "\t", " "]
let s:wordchar = split("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$", '\zs')
let s:digits = split("0123456789", '\zs')
"<!-- is a special case (ok, it"s a minor hack actually)
let s:punct = split("+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::", " ")
let s:line_starters = split("continue,try,throw,return,var,if,switch,case,default,for,while,break", ",")
let s:current_mode = "BLOCK"
let s:modes = [s:current_mode]
let s:parser_pos = 0
let s:in_case = 0
while 1
let t = s:get_next_token()
let s:token_text = t[0]
let s:token_type = t[1]
if s:token_type == "TK_EOF"
break
endif
try
if s:token_type == "TK_START_EXPR"
let s:var_line = 0
call s:set_mode("EXPRESSION")
if s:last_text == ";"
call s:print_newline(1)
elseif s:last_type == "TK_END_EXPR" || s:last_type == "TK_START_EXPR"
" do nothing on (( and )( and ][ and ]( ..
elseif s:last_type != "TK_WORD" && s:last_type != "TK_OPERATOR"
call s:print_space()
elseif s:in_array(s:last_word, s:line_starters)
call s:print_space()
endif
call s:print_token()
elseif s:token_type == "TK_END_EXPR"
call s:print_token()
call s:restore_mode()
elseif s:token_type == "TK_START_BLOCK"
if s:last_word == "do"
call s:set_mode("DO_BLOCK")
else
call s:set_mode("BLOCK")
endif
if s:last_type != "TK_OPERATOR" && s:last_type != "TK_START_EXPR"
if s:last_type == "TK_START_BLOCK"
call s:print_newline(1)
else
call s:print_space()
endif
endif
call s:print_token()
call s:indent()
elseif s:token_type == "TK_END_BLOCK"
if s:last_type == "TK_START_BLOCK"
call s:remove_indent()
call s:unindent()
else
call s:unindent()
call s:print_newline(1)
endif
call s:print_token()
call s:restore_mode()
elseif s:token_type == "TK_WORD"
if s:do_block_just_closed
" do {} ## while ()
call s:print_space()
call s:print_token()
call s:print_space()
let s:do_block_just_closed = 0
throw "jump out"
endif
if s:token_text == "case" || s:token_text == "default"
if s:last_text == ":"
"switch cases following one another
call s:remove_indent()
else
" case statement starts in the same line where switch
call s:unindent()
call s:print_newline(1)
call s:indent()
endif
call s:print_token()
let s:in_case = 1
throw "jump out"
endif
let s:prefix = "NONE"
if s:last_type == "TK_END_BLOCK"
if !s:in_array(tolower(s:token_text), ["else", "catch", "finally"])
let s:prefix = "NEWLINE"
else
let s:prefix = "SPACE"
call s:print_space()
endif
elseif s:last_type == "TK_SEMICOLON" && (s:current_mode == "BLOCK" || s:current_mode == "DO_BLOCK")
let s:prefix = "NEWLINE"
elseif s:last_type == "TK_SEMICOLON" && s:current_mode == "EXPRESSION"
let s:prefix = "SPACE"
elseif s:last_type == "TK_STRING"
let s:prefix = "NEWLINE"
elseif s:last_type == "TK_WORD"
let s:prefix = "SPACE"
elseif s:last_type == "TK_START_BLOCK"
let s:prefix = "NEWLINE"
elseif s:last_type == "TK_END_EXPR"
call s:print_space()
let s:prefix = "NEWLINE"
endif
if s:last_type != "TK_END_BLOCK" && s:in_array(tolower(s:token_text), ["else", "catch", "finally"])
call s:print_newline(1)
elseif s:in_array(s:token_text, s:line_starters) || s:prefix == "NEWLINE"
if s:last_text == "else"
call s:print_space()
elseif (s:last_type == "TK_START_EXPR" || s:last_text == "=" || s:last_text == ",") && s:token_text == "function"
" no need to force newline on "function":
" DONOTHINT
elseif s:last_type == "TK_WORD" && (s:last_text == "return" || s:last_text == "throw")
" no newline between "return nnn"
call s:print_space()
elseif s:last_type != "TK_END_EXPR"
if (s:last_type != "TK_START_EXPR" || s:token_text != "var") && s:last_text != ":"
" no need to force newline on "var": for (var
" x = 0...)
if s:token_text == "if" && s:last_type == "TK_WORD" && s:last_word == "else"
" no newline for } else if {
call s:print_space()
else
call s:print_newline(1)
endif
endif
else
if s:in_array(s:token_text, s:line_starters) && s:last_text != ")"
call s:print_newline(1)
endif
endif
elseif s:prefix == "SPACE"
call s:print_space()
endif
call s:print_token()
let s:last_word = s:token_text
if s:token_text == "var"
let s:var_line = 1
let s:var_line_tainted = 0
endif
if s:token_text == "if" || s:token_text == "else"
let s:if_line_flag = 1
endif
elseif s:token_type == "TK_SEMICOLON"
call s:print_token()
let s:var_line = 0
elseif s:token_type == "TK_STRING"
if s:last_type == "TK_START_BLOCK" || s:last_type == "TK_END_BLOCK" || s:last_type == "TK_SEMICOLON"
call s:print_newline(1)
elseif s:last_type == "TK_WORD"
call s:print_space()
endif
call s:print_token()
elseif s:token_type == "TK_OPERATOR"
let start_delim = 1
let end_delim = 1
if s:var_line && s:token_text != ","
let s:var_line_tainted = 1
if s:token_text == ":"
let s:var_line = 0
endif
endif
if s:var_line && s:token_text=="," && s:current_mode == "EXPRESSION"
" do not break on comma, for(var a = 1, b = 2)
let s:var_line_tainted = 0
endif
if s:token_text == ":" && s:in_case
call s:print_token()
call s:print_newline(1)
throw "jump out"
endif
if s:token_text == "::"
" no spaces around exotic namespacing syntax operator
call s:print_token()
throw "jump out"
endif
let s:in_case = 0
if s:token_text == ","
if s:var_line
if s:var_line_tainted
call s:print_token()
call s:print_newline(1)
let s:var_line_tainted = 0
else
call s:print_token()
call s:print_space()
endif
elseif s:last_type == "TK_END_BLOCK"
call s:print_token()
call s:print_newline(1)
else
if s:current_mode == "BLOCK"
call s:print_token()
call s:print_newline(1)
else
" EXPR od DO_BLOCK
call s:print_token()
call s:print_space()
endif
endif
throw "jump out"
elseif s:token_text == "--" || s:token_text == "++" " unary operators special case
if s:last_text == ";"
" space for (;; ++i)
let start_delim = 1
let end_delim = 0
else
let start_delim = 0
let end_delim = 0
endif
elseif s:token_text == "!" && s:last_type == "TK_START_EXPR"
" special case handling: if (!a)
let start_delim = 0
let end_delim = 0
elseif s:last_type == "TK_OPERATOR"
let s:start_delim = 0
let s:end_delim = 0
elseif s:last_type == "TK_END_EXPR"
let s:start_delim = 1
let s:end_delim = 1
elseif s:token_text == "."
" decimal digits or object.property
let start_delim = 0
let end_delim = 0
elseif s:token_text == ":"
" zz: xx
" can"t differentiate ternary op, so for now it"s a ? b:
" c;without space before colon
if s:last_text =~ '/^\d+$/'
" a little help for ternary a ? 1 : 0
let start_delim = 1
else
let start_delim = 0
endif
endif
if start_delim
call s:print_space()
endif
call s:print_token()
if end_delim
call s:print_space()
endif
throw "jump out"
elseif s:token_type == "TK_BLOCK_COMMENT"
call s:print_newline(1)
call s:print_token()
call s:print_newline(1)
elseif s:token_type == "TK_COMMENT"
"call s:print_newline(1)
call s:print_space()
call s:print_token()
call s:print_newline(1)
elseif s:token_type == "TK_UNKNOWN"
call s:print_token()
throw "jump out"
endif
catch /.*/
if v:exception != 'jump out'
echo "exception caught: " v:exception
endif
endtry
let s:last_type = s:token_type
let s:last_text = s:token_text
endwhile
let ret = join(s:output, "")
:g/.*/d
let @0 = ret
:put!0
endfunction
nnoremap <silent> <leader>ff :call g:Jsbeautify()<cr>

View File

@ -0,0 +1,31 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=2896
Some vim user want to shell like emacs's eshell. But vim don't support shell,
terminal interface in vim (at least 7.x version).
In this situation, I try some terminal patches or shell attached plugins. But everyone don't perfectly emulate native terminal or have much dependencies. So I use simple native terminal and filemanager open script for my various platforms.
Commmands
:OpenTerminal Open native terminal sw.
:OpenFilemanager Open native file manager.
Key map recommendations (I'm using)
nnoremap <silent> <F9> :OpenTerminal<CR>
nnoremap <silent> <F10> :OpenFilemanager<CR><CR>
Tested platform
* Mac ~ Terminal.app, finder
* MacVim
* Windows 7 64bit, XP ~cmd.exe , explorer
* [portable] gVim
* Gnome ~ gnome-terminal, nautilus
* gVim
This is very simple script. If plugin show wrong operation feedback to me. I can't test in windows xp, KDE etc :)

View File

@ -0,0 +1,71 @@
*open-terminal* Open Terminal, Filemanager for various platform
Open Terminal Help File
Introduction |open-terminal-introduction|
Commmands |open-terminal-commands|
Requires |open-terminal-requires|
Key map examples |open-terminal-keymap|
Changelog |open-terminal-changelog|
About |open-terminal-about|
==============================================================================
Introduction *open-terminal-introduction*
Some vim user want to shell like emacs's eshell. But vim don't support shell,
terminal interface in vim (at least 7.x version).
In this situation, I use native terminal software open script for my various
working platforms.
==============================================================================
Commmands *open-terminal-commands*
*OpenTerminal*
:OpenTerminal Open native terminal sw. Check |requires| list
*OpenFilemanager*
:OpenFilemanager Open native file manager. Check |requires| list
==============================================================================
Map key examples *open-terminal-keymap*
>
nnoremap <silent> <F9> :OpenTerminal<CR>
nnoremap <silent> <F10> :OpenFilemanager<CR><CR>
<
==============================================================================
Requires (per platform) *open-terminal-requires*
I use Mac, Gnome, Windows(gvim). I don't test in KDE environment.
Platform Terminal File manager ~
>
Mac Terminal.app Finder
(with Applescript)
Gnome gnome-terminal nautilus
KDE konsole konqueror
Windows cmd explorer
(with start)
cygwin bash explorer
<
==============================================================================
Changelog *open-terminal-changelog*
0.1:
- First release used script for everyone.
==============================================================================
About *open-terminal-about*
Copyright (c) 2009 by neocoin ~
File: open_terminal.vim
Author: Sangmin Ryu (neocoin@gmail.com)
Date: Tue Dec 22 13:33:32 PST 2009
License: The MIT License
==============================================================================
vim:tw=78:ts=8:ft=help:norl:

View File

@ -0,0 +1,9 @@
OpenFilemanager open_terminal.txt /*OpenFilemanager*
OpenTerminal open_terminal.txt /*OpenTerminal*
open-terminal open_terminal.txt /*open-terminal*
open-terminal-about open_terminal.txt /*open-terminal-about*
open-terminal-changelog open_terminal.txt /*open-terminal-changelog*
open-terminal-commands open_terminal.txt /*open-terminal-commands*
open-terminal-introduction open_terminal.txt /*open-terminal-introduction*
open-terminal-keymap open_terminal.txt /*open-terminal-keymap*
open-terminal-requires open_terminal.txt /*open-terminal-requires*

View File

@ -0,0 +1,11 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=3504
taglist-plus.vim
================
This is a fork of the popular taglist.vim plugin.
Taglist-plus supports jsctags for excellent Javascript tagging. See [here][1]
for examples.
[1]:http://discontinuously.com/2011/03/vim-support-javascript-taglist-plus/

View File

@ -0,0 +1,42 @@
taglist-plus.vim
================
This is a fork of the popular taglist.vim plugin.
Taglist-plus provides excellent Javascript support via jsctags. See [here][1]
for examples.
This plugin can also be obtained through [vim.org][2].
Installation
------------
Unzip the plugin files to your `.vim` directory.
For great Javascript support, jsctags is required as well.
jsctags can be obtained via [github][4]. It requires a recent version of
node.js -- the default one provided in Maverick Meerkat won't cut it. You can
[build it from source][6] or get it via [this PPA][5].
If you're going the PPA route, you'll need to map `nodejs` to `node`. Here are
the commands:
<pre>
sudo add-apt-repository ppa:richarvey/nodester
sudo apt-get update
sudo apt-get install nodejs
sudo ln -s /usr/bin/nodejs /usr/local/bin/node
</pre>
Usage
-----
`:TlistToggle` brings up the taglist window. More commands can be found via
`:help taglist-commands`.
[1]:http://discontinuously.com/2011/03/vim-support-javascript-taglist-plus/
[2]:https://github.com/int3/vim-taglist-plus
[3]:http://www.vim.org/scripts/script.php?script_id=3504
[4]:https://github.com/mozilla/doctorjs
[5]:https://launchpad.net/~richarvey/+archive/nodester
[6]:http://nodejs.org/#download

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
'Tlist_Auto_Highlight_Tag' taglist-plus.txt /*'Tlist_Auto_Highlight_Tag'*
'Tlist_Auto_Open' taglist-plus.txt /*'Tlist_Auto_Open'*
'Tlist_Auto_Update' taglist-plus.txt /*'Tlist_Auto_Update'*
'Tlist_Close_On_Select' taglist-plus.txt /*'Tlist_Close_On_Select'*
'Tlist_Compact_Format' taglist-plus.txt /*'Tlist_Compact_Format'*
'Tlist_Ctags_Cmd' taglist-plus.txt /*'Tlist_Ctags_Cmd'*
'Tlist_Display_Prototype' taglist-plus.txt /*'Tlist_Display_Prototype'*
'Tlist_Display_Tag_Scope' taglist-plus.txt /*'Tlist_Display_Tag_Scope'*
'Tlist_Enable_Fold_Column' taglist-plus.txt /*'Tlist_Enable_Fold_Column'*
'Tlist_Exit_OnlyWindow' taglist-plus.txt /*'Tlist_Exit_OnlyWindow'*
'Tlist_File_Fold_Auto_Close' taglist-plus.txt /*'Tlist_File_Fold_Auto_Close'*
'Tlist_GainFocus_On_ToggleOpen' taglist-plus.txt /*'Tlist_GainFocus_On_ToggleOpen'*
'Tlist_Highlight_Tag_On_BufEnter' taglist-plus.txt /*'Tlist_Highlight_Tag_On_BufEnter'*
'Tlist_Inc_Winwidth' taglist-plus.txt /*'Tlist_Inc_Winwidth'*
'Tlist_Max_Submenu_Items' taglist-plus.txt /*'Tlist_Max_Submenu_Items'*
'Tlist_Max_Tag_Length' taglist-plus.txt /*'Tlist_Max_Tag_Length'*
'Tlist_Process_File_Always' taglist-plus.txt /*'Tlist_Process_File_Always'*
'Tlist_Show_Menu' taglist-plus.txt /*'Tlist_Show_Menu'*
'Tlist_Show_One_File' taglist-plus.txt /*'Tlist_Show_One_File'*
'Tlist_Sort_Type' taglist-plus.txt /*'Tlist_Sort_Type'*
'Tlist_Use_Horiz_Window' taglist-plus.txt /*'Tlist_Use_Horiz_Window'*
'Tlist_Use_Right_Window' taglist-plus.txt /*'Tlist_Use_Right_Window'*
'Tlist_Use_SingleClick' taglist-plus.txt /*'Tlist_Use_SingleClick'*
'Tlist_WinHeight' taglist-plus.txt /*'Tlist_WinHeight'*
'Tlist_WinWidth' taglist-plus.txt /*'Tlist_WinWidth'*
'Tlist_javascript_Hide_Extras' taglist-plus.txt /*'Tlist_javascript_Hide_Extras'*
:TlistAddFiles taglist-plus.txt /*:TlistAddFiles*
:TlistAddFilesRecursive taglist-plus.txt /*:TlistAddFilesRecursive*
:TlistClose taglist-plus.txt /*:TlistClose*
:TlistDebug taglist-plus.txt /*:TlistDebug*
:TlistHighlightTag taglist-plus.txt /*:TlistHighlightTag*
:TlistLock taglist-plus.txt /*:TlistLock*
:TlistMessages taglist-plus.txt /*:TlistMessages*
:TlistOpen taglist-plus.txt /*:TlistOpen*
:TlistSessionLoad taglist-plus.txt /*:TlistSessionLoad*
:TlistSessionSave taglist-plus.txt /*:TlistSessionSave*
:TlistShowPrototype taglist-plus.txt /*:TlistShowPrototype*
:TlistShowTag taglist-plus.txt /*:TlistShowTag*
:TlistToggle taglist-plus.txt /*:TlistToggle*
:TlistUndebug taglist-plus.txt /*:TlistUndebug*
:TlistUnlock taglist-plus.txt /*:TlistUnlock*
:TlistUpdate taglist-plus.txt /*:TlistUpdate*
Tlist_Get_Tag_Prototype_By_Line() taglist-plus.txt /*Tlist_Get_Tag_Prototype_By_Line()*
Tlist_Get_Tagname_By_Line() taglist-plus.txt /*Tlist_Get_Tagname_By_Line()*
Tlist_Set_App() taglist-plus.txt /*Tlist_Set_App()*
Tlist_Update_File_Tags() taglist-plus.txt /*Tlist_Update_File_Tags()*
taglist-commands taglist-plus.txt /*taglist-commands*
taglist-debug taglist-plus.txt /*taglist-debug*
taglist-extend taglist-plus.txt /*taglist-extend*
taglist-faq taglist-plus.txt /*taglist-faq*
taglist-functions taglist-plus.txt /*taglist-functions*
taglist-install taglist-plus.txt /*taglist-install*
taglist-intro taglist-plus.txt /*taglist-intro*
taglist-keys taglist-plus.txt /*taglist-keys*
taglist-license taglist-plus.txt /*taglist-license*
taglist-menu taglist-plus.txt /*taglist-menu*
taglist-options taglist-plus.txt /*taglist-options*
taglist-plus.txt taglist-plus.txt /*taglist-plus.txt*
taglist-requirements taglist-plus.txt /*taglist-requirements*
taglist-session taglist-plus.txt /*taglist-session*
taglist-todo taglist-plus.txt /*taglist-todo*
taglist-using taglist-plus.txt /*taglist-using*

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=90
VIM 7 plugin useful for manipulating files controlled by CVS, SVN, SVK, git, bzr, and hg within VIM, including committing changes and performing diffs using the vimdiff system. Keywords: bazaar bzr cvs CVS cvscommand git mercurial hg subversion SVN svk vcscommand
The source for this plugin is available in git at git://repo.or.cz/vcscommand . A web front end is available at http://repo.or.cz/w/vcscommand.git .
Please submit any issues at http://code.google.com/p/vcscommand/

View File

@ -0,0 +1,78 @@
:CVSEdit vcscommand.txt /*:CVSEdit*
:CVSEditors vcscommand.txt /*:CVSEditors*
:CVSUnedit vcscommand.txt /*:CVSUnedit*
:CVSWatch vcscommand.txt /*:CVSWatch*
:CVSWatchAdd vcscommand.txt /*:CVSWatchAdd*
:CVSWatchOff vcscommand.txt /*:CVSWatchOff*
:CVSWatchOn vcscommand.txt /*:CVSWatchOn*
:CVSWatchRemove vcscommand.txt /*:CVSWatchRemove*
:CVSWatchers vcscommand.txt /*:CVSWatchers*
:VCSAdd vcscommand.txt /*:VCSAdd*
:VCSAnnotate vcscommand.txt /*:VCSAnnotate*
:VCSBlame vcscommand.txt /*:VCSBlame*
:VCSCommit vcscommand.txt /*:VCSCommit*
:VCSDelete vcscommand.txt /*:VCSDelete*
:VCSDiff vcscommand.txt /*:VCSDiff*
:VCSGotoOriginal vcscommand.txt /*:VCSGotoOriginal*
:VCSInfo vcscommand.txt /*:VCSInfo*
:VCSLock vcscommand.txt /*:VCSLock*
:VCSLog vcscommand.txt /*:VCSLog*
:VCSRemove vcscommand.txt /*:VCSRemove*
:VCSRevert vcscommand.txt /*:VCSRevert*
:VCSReview vcscommand.txt /*:VCSReview*
:VCSStatus vcscommand.txt /*:VCSStatus*
:VCSUnlock vcscommand.txt /*:VCSUnlock*
:VCSUpdate vcscommand.txt /*:VCSUpdate*
:VCSVimDiff vcscommand.txt /*:VCSVimDiff*
VCSCommandCVSDiffOpt vcscommand.txt /*VCSCommandCVSDiffOpt*
VCSCommandCVSExec vcscommand.txt /*VCSCommandCVSExec*
VCSCommandCommitOnWrite vcscommand.txt /*VCSCommandCommitOnWrite*
VCSCommandDeleteOnHide vcscommand.txt /*VCSCommandDeleteOnHide*
VCSCommandDiffSplit vcscommand.txt /*VCSCommandDiffSplit*
VCSCommandDisableAll vcscommand.txt /*VCSCommandDisableAll*
VCSCommandDisableExtensionMappings vcscommand.txt /*VCSCommandDisableExtensionMappings*
VCSCommandDisableMappings vcscommand.txt /*VCSCommandDisableMappings*
VCSCommandDisableMenu vcscommand.txt /*VCSCommandDisableMenu*
VCSCommandEdit vcscommand.txt /*VCSCommandEdit*
VCSCommandEnableBufferSetup vcscommand.txt /*VCSCommandEnableBufferSetup*
VCSCommandMapPrefix vcscommand.txt /*VCSCommandMapPrefix*
VCSCommandMappings vcscommand.txt /*VCSCommandMappings*
VCSCommandMenuPriority vcscommand.txt /*VCSCommandMenuPriority*
VCSCommandMenuRoot vcscommand.txt /*VCSCommandMenuRoot*
VCSCommandResultBufferNameExtension vcscommand.txt /*VCSCommandResultBufferNameExtension*
VCSCommandResultBufferNameFunction vcscommand.txt /*VCSCommandResultBufferNameFunction*
VCSCommandSVKExec vcscommand.txt /*VCSCommandSVKExec*
VCSCommandSVNDiffExt vcscommand.txt /*VCSCommandSVNDiffExt*
VCSCommandSVNDiffOpt vcscommand.txt /*VCSCommandSVNDiffOpt*
VCSCommandSVNExec vcscommand.txt /*VCSCommandSVNExec*
VCSCommandSplit vcscommand.txt /*VCSCommandSplit*
VCSCommandVCSTypeOverride vcscommand.txt /*VCSCommandVCSTypeOverride*
VCSCommandVCSTypePreference vcscommand.txt /*VCSCommandVCSTypePreference*
b:VCSCommandCommand vcscommand.txt /*b:VCSCommandCommand*
b:VCSCommandOriginalBuffer vcscommand.txt /*b:VCSCommandOriginalBuffer*
b:VCSCommandSourceFile vcscommand.txt /*b:VCSCommandSourceFile*
b:VCSCommandVCSType vcscommand.txt /*b:VCSCommandVCSType*
cvscommand-changes vcscommand.txt /*cvscommand-changes*
vcscommand vcscommand.txt /*vcscommand*
vcscommand-buffer-management vcscommand.txt /*vcscommand-buffer-management*
vcscommand-buffer-variables vcscommand.txt /*vcscommand-buffer-variables*
vcscommand-bugs vcscommand.txt /*vcscommand-bugs*
vcscommand-commands vcscommand.txt /*vcscommand-commands*
vcscommand-config vcscommand.txt /*vcscommand-config*
vcscommand-contents vcscommand.txt /*vcscommand-contents*
vcscommand-customize vcscommand.txt /*vcscommand-customize*
vcscommand-events vcscommand.txt /*vcscommand-events*
vcscommand-install vcscommand.txt /*vcscommand-install*
vcscommand-intro vcscommand.txt /*vcscommand-intro*
vcscommand-manual vcscommand.txt /*vcscommand-manual*
vcscommand-mappings vcscommand.txt /*vcscommand-mappings*
vcscommand-mappings-override vcscommand.txt /*vcscommand-mappings-override*
vcscommand-naming vcscommand.txt /*vcscommand-naming*
vcscommand-options vcscommand.txt /*vcscommand-options*
vcscommand-ssh vcscommand.txt /*vcscommand-ssh*
vcscommand-ssh-config vcscommand.txt /*vcscommand-ssh-config*
vcscommand-ssh-env vcscommand.txt /*vcscommand-ssh-env*
vcscommand-ssh-other vcscommand.txt /*vcscommand-ssh-other*
vcscommand-ssh-wrapper vcscommand.txt /*vcscommand-ssh-wrapper*
vcscommand-statusline vcscommand.txt /*vcscommand-statusline*
vcscommand.txt vcscommand.txt /*vcscommand.txt*

View File

@ -0,0 +1,843 @@
*vcscommand.txt* vcscommand
Copyright (c) Bob Hiestand
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
For instructions on installing this file, type
:help add-local-help
inside Vim.
Author: Bob Hiestand <bob.hiestand@gmail.com>
Credits: Benji Fisher's excellent MatchIt documentation
==============================================================================
1. Contents *vcscommand-contents*
Installation : |vcscommand-install|
vcscommand Intro : |vcscommand|
vcscommand Manual : |vcscommand-manual|
Customization : |vcscommand-customize|
SSH "integration" : |vcscommand-ssh|
Changes from cvscommand : |cvscommand-changes|
Bugs : |vcscommand-bugs|
==============================================================================
2. vcscommand Installation *vcscommand-install*
The vcscommand plugin comprises five files: vcscommand.vim, vcssvn.vim,
vcscvs.vim, vcssvk.vim and vcscommand.txt (this file). In order to install
the plugin, place the vcscommand.vim, vcssvn.vim, vcssvk.vim, and vcscvs.vim
files into a plugin directory in your runtime path (please see
|add-global-plugin| and |'runtimepath'|.
This help file can be included in the VIM help system by copying it into a
'doc' directory in your runtime path and then executing the |:helptags|
command, specifying the full path of the 'doc' directory. Please see
|add-local-help| for more details.
vcscommand may be customized by setting variables, creating maps, and
specifying event handlers. Please see |vcscommand-customize| for more
details.
==============================================================================
3. vcscommand Intro *vcscommand*
*vcscommand-intro*
The vcscommand plugin provides global ex commands for manipulating
version-controlled source files, currently those controlled either by CVS or
Subversion. In general, each command operates on the current buffer and
accomplishes a separate source control function, such as update, commit, log,
and others (please see |vcscommand-commands| for a list of all available
commands). The results of each operation are displayed in a scratch buffer.
Several buffer variables are defined for those scratch buffers (please see
|vcscommand-buffer-variables|).
The notion of "current file" means either the current buffer, or, in the case
of a directory buffer (such as Explorer or netrw buffers), the directory (and
all subdirectories) represented by the the buffer.
For convenience, any vcscommand invoked on a vcscommand scratch buffer acts as
though it was invoked on the original file and splits the screen so that the
output appears in a new window.
Many of the commands accept revisions as arguments. By default, most operate
on the most recent revision on the current branch if no revision is specified.
Each vcscommand is mapped to a key sequence starting with the |<Leader>|
keystroke. The default mappings may be overridden by supplying different
mappings before the plugin is loaded, such as in the vimrc, in the standard
fashion for plugin mappings. For examples, please see
|vcscommand-mappings-override|.
The vcscommand plugin may be configured in several ways. For more details,
please see |vcscommand-customize|.
==============================================================================
4. vcscommand Manual *vcscommand-manual*
4.1 vcscommand commands *vcscommand-commands*
vcscommand defines the following commands:
|:VCSAdd|
|:VCSAnnotate|
|:VCSBlame|
|:VCSCommit|
|:VCSDelete|
|:VCSDiff|
|:VCSGotoOriginal|
|:VCSLog|
|:VCSRemove|
|:VCSRevert|
|:VCSReview|
|:VCSStatus|
|:VCSUpdate|
|:VCSVimDiff|
The following commands are specific to CVS files:
|:CVSEdit|
|:CVSEditors|
|:CVSUnedit|
|:CVSWatch|
|:CVSWatchAdd|
|:CVSWatchOn|
|:CVSWatchOff|
|:CVSWatchRemove|
|:CVSWatchers|
:VCSAdd *:VCSAdd*
This command adds the current file to source control. Please note, this does
not commit the newly-added file. All parameters to the command are passed to
the underlying VCS.
:VCSAnnotate[!] *:VCSAnnotate*
This command displays the current file with each line annotated with the
version in which it was most recently changed. If an argument is given, the
argument is used as a revision number to display. If not given an argument,
it uses the most recent version of the file (on the current branch, if under
CVS control). Additionally, if the current buffer is a VCSAnnotate buffer
already, the version number on the current line is used.
If '!' is used, the view of the annotated buffer is split so that the
annotation is in a separate window from the content, and each is highlighted
separately.
For CVS buffers, the 'VCSCommandCVSAnnotateParent' option, if set to non-zero,
will cause the above behavior to change. Instead of annotating the version on
the current line, the parent revision is used instead, crossing branches if
necessary.
With no arguments the cursor will jump to the line in the annotated buffer
corresponding to the current line in the source buffer.
:VCSBlame[!] *:VCSBlame*
Alias for |:VCSAnnotate|.
:VCSCommit[!] *:VCSCommit*
This command commits changes to the current file to source control.
If called with arguments, the arguments are the log message.
If '!' is used, an empty log message is committed.
If called with no arguments, this is a two-step command. The first step opens
a buffer to accept a log message. When that buffer is written, it is
automatically closed and the file is committed using the information from that
log message. The commit can be abandoned if the log message buffer is deleted
or wiped before being written.
Alternatively, the mapping that is used to invoke :VCSCommit (by default
|<Leader>|cc, please see |vcscommand-mappings|) can be used in the log message
buffer in Normal mode to immediately commit. This is useful if the
|VCSCommandCommitOnWrite| variable is set to 0 to disable the normal
commit-on-write behavior.
:VCSDelete *:VCSDelete*
Deletes the current file and removes it from source control. All parameters
to the command are passed to the underlying VCS.
:VCSDiff *:VCSDiff*
With no arguments, this displays the differences between the current file and
its parent version under source control in a new scratch buffer.
With one argument, the diff is performed on the current file against the
specified revision.
With two arguments, the diff is performed between the specified revisions of
the current file.
For CVS, this command uses the |VCSCommandCVSDiffOpt| variable to specify diff
options. If that variable does not exist, a plugin-specific default is used.
If you wish to have no options, then set it to the empty string.
For SVN, this command uses the |VCSCommandSVNDiffOpt| variable to specify diff
options. If that variable does not exist, the SVN default is used.
Additionally, |VCSCommandSVNDiffExt| can be used to select an external diff
application.
:VCSGotoOriginal *:VCSGotoOriginal*
This command jumps to the source buffer if the current buffer is a VCS scratch
buffer.
:VCSGotoOriginal!
Like ":VCSGotoOriginal" but also executes :bufwipeout on all VCS scrach
buffers associated with the original file.
:VCSInfo *:VCSInfo*
This command displays extended information about the current file in a new
scratch buffer.
:VCSLock *:VCSLock*
This command locks the current file in order to prevent other users from
concurrently modifying it. The exact semantics of this command depend on the
underlying VCS. This does nothing in CVS. All parameters are passed to the
underlying VCS.
:VCSLog *:VCSLog*
Displays the version history of the current file in a new scratch buffer. If
there is one parameter supplied, it is taken as as a revision parameters to be
passed through to the underlying VCS. Otherwise, all parameters are passed to
the underlying VCS.
:VCSRemove *:VCSRemove*
Alias for |:VCSDelete|.
:VCSRevert *:VCSRevert*
This command replaces the current file with the most recent version from the
repository in order to wipe out any undesired changes.
:VCSReview *:VCSReview*
Displays a particular version of the current file in a new scratch buffer. If
no argument is given, the most recent version of the file on the current
branch is retrieved.
:VCSStatus *:VCSStatus*
Displays versioning information about the current file in a new scratch
buffer. All parameters are passed to the underlying VCS.
:VCSUnlock *:VCSUnlock*
Unlocks the current file in order to allow other users from concurrently
modifying it. The exact semantics of this command depend on the underlying
VCS. All parameters are passed to the underlying VCS.
:VCSUpdate *:VCSUpdate*
Updates the current file with any relevant changes from the repository. This
intentionally does not automatically reload the current buffer, though vim
should prompt the user to do so if the underlying file is altered by this
command.
:VCSVimDiff *:VCSVimDiff*
Uses vimdiff to display differences between versions of the current file.
If no revision is specified, the most recent version of the file on the
current branch is used. With one argument, that argument is used as the
revision as above. With two arguments, the differences between the two
revisions is displayed using vimdiff.
With either zero or one argument, the original buffer is used to perform the
vimdiff. When the scratch buffer is closed, the original buffer will be
returned to normal mode.
Once vimdiff mode is started using the above methods, additional vimdiff
buffers may be added by passing a single version argument to the command.
There may be up to 4 vimdiff buffers total.
Using the 2-argument form of the command resets the vimdiff to only those 2
versions. Additionally, invoking the command on a different file will close
the previous vimdiff buffers.
:CVSEdit *:CVSEdit*
This command performs "cvs edit" on the current file. Yes, the output buffer
in this case is almost completely useless.
:CVSEditors *:CVSEditors*
This command performs "cvs edit" on the current file.
:CVSUnedit *:CVSUnedit*
Performs "cvs unedit" on the current file. Again, yes, the output buffer here
is basically useless.
:CVSWatch *:CVSWatch*
This command takes an argument which must be one of [on|off|add|remove]. The
command performs "cvs watch" with the given argument on the current file.
:CVSWatchAdd *:CVSWatchAdd*
This command is an alias for ":CVSWatch add"
:CVSWatchOn *:CVSWatchOn*
This command is an alias for ":CVSWatch on"
:CVSWatchOff *:CVSWatchOff*
This command is an alias for ":CVSWatch off"
:CVSWatchRemove *:CVSWatchRemove*
This command is an alias for ":CVSWatch remove"
:CVSWatchers *:CVSWatchers*
This command performs "cvs watchers" on the current file.
4.2 Mappings *vcscommand-mappings*
By default, a mapping is defined for each command. These mappings execute the
default (no-argument) form of each command.
|<Leader>|ca VCSAdd
|<Leader>|cn VCSAnnotate
|<Leader>|cN VCSAnnotate!
|<Leader>|cc VCSCommit
|<Leader>|cD VCSDelete
|<Leader>|cd VCSDiff
|<Leader>|cg VCSGotoOriginal
|<Leader>|cG VCSGotoOriginal!
|<Leader>|ci VCSInfo
|<Leader>|cl VCSLog
|<Leader>|cL VCSLock
|<Leader>|cr VCSReview
|<Leader>|cs VCSStatus
|<Leader>|cu VCSUpdate
|<Leader>|cU VCSUnlock
|<Leader>|cv VCSVimDiff
Only for CVS buffers:
|<Leader>|ce CVSEdit
|<Leader>|cE CVSEditors
|<Leader>|ct CVSUnedit
|<Leader>|cwv CVSWatchers
|<Leader>|cwa CVSWatchAdd
|<Leader>|cwn CVSWatchOn
|<Leader>|cwf CVSWatchOff
|<Leader>|cwf CVSWatchRemove
*vcscommand-mappings-override*
The default mappings can be overridden by user-provided instead by mapping to
<Plug>CommandName. This is especially useful when these mappings collide with
other existing mappings (vim will warn of this during plugin initialization,
but will not clobber the existing mappings).
There are three methods for controlling mapping:
First, maps can be overriden for individual commands. For instance, to
override the default mapping for :VCSAdd to set it to '\add', add the
following to the vimrc:
nmap \add <Plug>VCSAdd
Second, the default map prefix ('<Leader>c') can be overridden by defining the
|VCSCommandMapPrefix| variable.
Third, the entire set of default maps can be overridden by defining the
|VCSCommandMappings| variable.
4.3 Automatic buffer variables *vcscommand-buffer-variables*
Several buffer variables are defined in each vcscommand result buffer. These
may be useful for additional customization in callbacks defined in the event
handlers (please see |vcscommand-events|).
The following variables are automatically defined:
b:VCSCommandOriginalBuffer *b:VCSCommandOriginalBuffer*
This variable is set to the buffer number of the source file.
b:VCSCommandCommand *b:VCSCommandCommand*
This variable is set to the name of the vcscommand that created the result
buffer.
b:VCSCommandSourceFile *b:VCSCommandSourceFile*
This variable is set to the name of the original file under source control.
b:VCSCommandVCSType *b:VCSCommandVCSType*
This variable is set to the type of the source control. This variable is also
set on the original file itself.
==============================================================================
5. Configuration and customization *vcscommand-customize*
*vcscommand-config*
The vcscommand plugin can be configured in several ways: by setting
configuration variables (see |vcscommand-options|) or by defining vcscommand
event handlers (see |vcscommand-events|). Additionally, the vcscommand plugin
supports a customized status line (see |vcscommand-statusline| and
|vcscommand-buffer-management|).
5.1 vcscommand configuration variables *vcscommand-options*
Several variables affect the plugin's behavior. These variables are checked
at time of execution, and may be defined at the window, buffer, or global
level and are checked in that order of precedence.
The following variables are available:
|VCSCommandCommitOnWrite|
|VCSCommandCVSDiffOpt|
|VCSCommandCVSExec|
|VCSCommandDeleteOnHide|
|VCSCommandDiffSplit|
|VCSCommandDisableAll|
|VCSCommandDisableMappings|
|VCSCommandDisableExtensionMappings|
|VCSCommandDisableMenu|
|VCSCommandEdit|
|VCSCommandEnableBufferSetup|
|VCSCommandMappings|
|VCSCommandMapPrefix|
|VCSCommandMenuPriority|
|VCSCommandMenuRoot|
|VCSCommandResultBufferNameExtension|
|VCSCommandResultBufferNameFunction|
|VCSCommandSplit|
|VCSCommandSVKExec|
|VCSCommandSVNDiffExt|
|VCSCommandSVNDiffOpt|
|VCSCommandSVNExec|
|VCSCommandVCSTypeOverride|
|VCSCommandVCSTypePreference|
VCSCommandCommitOnWrite *VCSCommandCommitOnWrite*
This variable, if set to a non-zero value, causes the pending commit
to take place immediately as soon as the log message buffer is written.
If set to zero, only the VCSCommit mapping will cause the pending commit to
occur. If not set, it defaults to 1.
VCSCommandCVSExec *VCSCommandCVSExec*
This variable controls the executable used for all CVS commands If not set,
it defaults to "cvs".
VCSCommandDeleteOnHide *VCSCommandDeleteOnHide*
This variable, if set to a non-zero value, causes the temporary result buffers
to automatically delete themselves when hidden.
VCSCommandCVSDiffOpt *VCSCommandCVSDiffOpt*
This variable, if set, determines the options passed to the diff command of
CVS. If not set, it defaults to 'u'.
VCSCommandDiffSplit *VCSCommandDiffSplit*
This variable overrides the |VCSCommandSplit| variable, but only for buffers
created with |:VCSVimDiff|.
VCSCommandDisableAll *VCSCommandDisableAll*
This variable, if set, prevents the plugin or any extensions from loading at
all. This is useful when a single runtime distribution is used on multiple
systems with varying versions.
VCSCommandDisableMappings *VCSCommandDisableMappings*
This variable, if set to a non-zero value, prevents the default command
mappings from being set. This supercedes
|VCSCommandDisableExtensionMappings|.
VCSCommandDisableExtensionMappings *VCSCommandDisableExtensionMappings*
This variable, if set to a non-zero value, prevents the default command
mappings from being set for commands specific to an individual VCS.
VCSCommandEdit *VCSCommandEdit*
This variable controls whether the original buffer is replaced ('edit') or
split ('split'). If not set, it defaults to 'split'.
VCSCommandDisableMenu *VCSCommandDisableMenu*
This variable, if set to a non-zero value, prevents the default command menu
from being set.
VCSCommandEnableBufferSetup *VCSCommandEnableBufferSetup*
This variable, if set to a non-zero value, activates VCS buffer management
mode see (|vcscommand-buffer-management|). This mode means that the
'VCSCommandBufferInfo' variable is filled with version information if the file
is VCS-controlled. This is useful for displaying version information in the
status bar.
VCSCommandMappings *VCSCommandMappings*
This variable, if set, overrides the default mappings used for shortcuts. It
should be a List of 2-element Lists, each containing a shortcut and function
name pair. The value of the '|VCSCommandMapPrefix|' variable will be added to
each shortcut.
VCSCommandMapPrefix *VCSCommandMapPrefix*
This variable, if set, overrides the default mapping prefix ('<Leader>c').
This allows customization of the mapping space used by the vcscommand
shortcuts.
VCSCommandMenuPriority *VCSCommandMenuPriority*
This variable, if set, overrides the default menu priority '' (empty)
VCSCommandMenuRoot *VCSCommandMenuRoot*
This variable, if set, overrides the default menu root 'Plugin.VCS'
VCSCommandResultBufferNameExtension *VCSCommandResultBufferNameExtension*
This variable, if set to a non-blank value, is appended to the name of the VCS
command output buffers. For example, '.vcs'. Using this option may help
avoid problems caused by autocommands dependent on file extension.
VCSCommandResultBufferNameFunction *VCSCommandResultBufferNameFunction*
This variable, if set, specifies a custom function for naming VCS command
output buffers. This function is expected to return the new buffer name, and
will be passed the following arguments:
command - name of the VCS command being executed (such as 'Log' or
'Diff').
originalBuffer - buffer number of the source file.
vcsType - type of VCS controlling this file (such as 'CVS' or 'SVN').
statusText - extra text associated with the VCS action (such as version
numbers).
VCSCommandSplit *VCSCommandSplit*
This variable controls the orientation of the various window splits that
may occur.
If set to 'horizontal', the resulting windows will be on stacked on top of
one another. If set to 'vertical', the resulting windows will be
side-by-side. If not set, it defaults to 'horizontal' for all but
VCSVimDiff windows. VCSVimDiff windows default to the user's 'diffopt'
setting, if set, otherwise 'vertical'.
VCSCommandSVKExec *VCSCommandSVKExec*
This variable controls the executable used for all SVK commands If not set,
it defaults to "svk".
VCSCommandSVNDiffExt *VCSCommandSVNDiffExt*
This variable, if set, is passed to SVN via the --diff-cmd command to select
an external application for performing the diff.
VCSCommandSVNDiffOpt *VCSCommandSVNDiffOpt*
This variable, if set, determines the options passed with the '-x' parameter
to the SVN diff command. If not set, no options are passed.
VCSCommandSVNExec *VCSCommandSVNExec*
This variable controls the executable used for all SVN commands If not set,
it defaults to "svn".
VCSCommandVCSTypeOverride *VCSCommandVCSTypeOverride*
This variable allows the VCS type detection to be overridden on a path-by-path
basis. The value of this variable is expected to be a List of Lists. Each
item in the high-level List is a List containing two elements. The first
element is a regular expression that will be matched against the full file
name of a given buffer. If it matches, the second element will be used as the
VCS type.
VCSCommandVCSTypePreference *VCSCommandVCSTypePreference*
This variable allows the VCS type detection to be weighted towards a specific
VCS, in case more than one potential VCS is detected as useable. The format
of the variable is either a list or a space-separated string containing the
ordered-by-preference abbreviations of the preferred VCS types.
5.2 VCSCommand events *vcscommand-events*
For additional customization, vcscommand can trigger user-defined events.
Event handlers are provided by defining User event autocommands (see
|autocommand|, |User|) in the vcscommand group with patterns matching the
event name.
For instance, the following could be added to the vimrc to provide a 'q'
mapping to quit a vcscommand scratch buffer:
augroup VCSCommand
au User VCSBufferCreated silent! nmap <unique> <buffer> q :bwipeout<cr>
augroup END
The following hooks are available:
VCSBufferCreated This event is fired just after a vcscommand
result buffer is created and populated. It is
executed within the context of the vcscommand
buffer. The vcscommand buffer variables may
be useful for handlers of this event (please
see |vcscommand-buffer-variables|).
VCSBufferSetup This event is fired just after vcscommand buffer
setup occurs, if enabled.
VCSPluginInit This event is fired when the vcscommand plugin
first loads.
VCSPluginFinish This event is fired just after the vcscommand
plugin loads.
VCSVimDiffFinish This event is fired just after the VCSVimDiff
command executes to allow customization of,
for instance, window placement and focus.
Additionally, there is another hook which is used internally to handle loading
the multiple scripts in order. This hook should probably not be used by an
end user without a good idea of how it works. Among other things, any events
associated with this hook are cleared after they are executed (during
vcscommand.vim script initialization).
VCSLoadExtensions This event is fired just before the
VCSPluginFinish. It is used internally to
execute any commands from the VCS
implementation plugins that needs to be
deferred until the primary plugin is
initialized.
5.3 vcscommand buffer naming *vcscommand-naming*
vcscommand result buffers use the following naming convention:
[{VCS type} {VCS command} {Source file name}]
If additional buffers are created that would otherwise conflict, a
distinguishing number is added:
[{VCS type} {VCS command} {Source file name}] (1,2, etc)
5.4 vcscommand status line support *vcscommand-statusline*
It is intended that the user will customize the |'statusline'| option to
include vcscommand result buffer attributes. A sample function that may be
used in the |'statusline'| option is provided by the plugin,
VCSCommandGetStatusLine(). In order to use that function in the status line, do
something like the following:
set statusline=%<%f\ %{VCSCommandGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P
of which %{VCSCommandGetStatusLine()} is the relevant portion.
The sample VCSCommandGetStatusLine() function handles both vcscommand result
buffers and VCS-managed files if vcscommand buffer management is enabled
(please see |vcscommand-buffer-management|).
5.5 vcscommand buffer management *vcscommand-buffer-management*
The vcscommand plugin can operate in buffer management mode, which means that
it attempts to set a buffer variable ('VCSCommandBufferInfo') upon entry into
a buffer. This is rather slow because it means that the VCS will be invoked
at each entry into a buffer (during the |BufEnter| autocommand).
This mode is disabled by default. In order to enable it, set the
|VCSCommandEnableBufferSetup| variable to a true (non-zero) value. Enabling
this mode simply provides the buffer variable mentioned above. The user must
explicitly include information from the variable in the |'statusline'| option
if they are to appear in the status line (but see |vcscommand-statusline| for
a simple way to do that).
The 'VCSCommandBufferInfo' variable is a list which contains, in order, the
revision of the current file, the latest revision of the file in the
repository, and (for CVS) the name of the branch. If those values cannot be
determined, the list is a single element: 'Unknown'.
==============================================================================
6. SSH "integration" *vcscommand-ssh*
The following instructions are intended for use in integrating the
vcscommand.vim plugin with an SSH-based CVS environment.
Familiarity with SSH and CVS are assumed.
These instructions assume that the intent is to have a message box pop up in
order to allow the user to enter a passphrase. If, instead, the user is
comfortable using certificate-based authentication, then only instructions
6.1.1 and 6.1.2 (and optionally 6.1.4) need to be followed; ssh should then
work transparently.
6.1 Environment settings *vcscommand-ssh-env*
6.1.1 CVSROOT should be set to something like:
:ext:user@host:/path_to_repository
6.1.2 CVS_RSH should be set to:
ssh
Together, those settings tell CVS to use ssh as the transport when
performing CVS calls.
6.1.3 SSH_ASKPASS should be set to the password-dialog program. In my case,
running gnome, it's set to:
/usr/libexec/openssh/gnome-ssh-askpass
This tells SSH how to get passwords if no input is available.
6.1.4 OPTIONAL. You may need to set SSH_SERVER to the location of the cvs
executable on the remote (server) machine.
6.2 CVS wrapper program *vcscommand-ssh-wrapper*
Now you need to convince SSH to use the password-dialog program. This means
you need to execute SSH (and therefore CVS) without standard input. The
following script is a simple perl wrapper that dissasociates the CVS command
from the current terminal. Specific steps to do this may vary from system to
system; the following example works for me on linux.
#!/usr/bin/perl -w
use strict;
use POSIX qw(setsid);
open STDIN, '/dev/null';
fork and do {wait; exit;};
setsid;
exec('cvs', @ARGV);
6.3 Configuring vcscommand.vim *vcscommand-ssh-config*
At this point, you should be able to use your wrapper script to invoke CVS with
various commands, and get the password dialog. All that's left is to make CVS
use your newly-created wrapper script.
6.3.1 Tell vcscommand.vim what CVS executable to use. The easiest way to do this
is globally, by putting the following in your .vimrc:
let VCSCommandCVSExec=/path/to/cvs/wrapper/script
6.4 Where to go from here *vcscommand-ssh-other*
The script given above works even when non-SSH CVS connections are used,
except possibly when interactively entering the message for CVS commit log
(depending on the editor you use... VIM works fine). Since the vcscommand.vim
plugin handles that message without a terminal, the wrapper script can be used
all the time.
This allows mixed-mode operation, where some work is done with SSH-based CVS
repositories, and others with pserver or local access.
It is possible, though beyond the scope of the plugin, to dynamically set the
CVS executable based on the CVSROOT for the file being edited. The user
events provided (such as VCSBufferCreated and VCSBufferSetup) can be used to
set a buffer-local value (b:VCSCommandCVSExec) to override the CVS executable
on a file-by-file basis. Alternatively, much the same can be done (less
automatically) by the various project-oriented plugins out there.
It is highly recommended for ease-of-use that certificates with no passphrase
or ssh-agent are employed so that the user is not given the password prompt
too often.
==============================================================================
7. Changes from cvscommand *cvscommand-changes*
1. Require Vim 7 in order to leverage several convenient features; also
because I wanted to play with Vim 7.
2. Renamed commands to start with 'VCS' instead of 'CVS'. The exceptions are
the 'CVSEdit' and 'CVSWatch' family of commands, which are specific to CVS.
3. Renamed options, events to start with 'VCSCommand'.
4. Removed option to jump to the parent version of the current line in an
annotated buffer, as opposed to the version on the current line. This made
little sense in the branching scheme used by subversion, where jumping to a
parent branch required finding a different location in the repository. It
didn't work consistently in CVS anyway.
5. Removed option to have nameless scratch buffers.
6. Changed default behavior of scratch buffers to split the window instead of
displaying in the current window. This may still be overridden using the
'VCSCommandEdit' option.
7. Split plugin into multiple plugins.
8. Added 'VCSLock' and 'VCSUnlock' commands. These are implemented for
subversion but not for CVS. These were not kept specific to subversion as they
seemed more general in nature and more likely to be supported by any future VCS
supported by this plugin.
9. Changed name of buffer variables set by commands.
'b:cvsOrigBuffNR' became 'b:VCSCommandOriginalBuffer'
'b:cvscmd' became 'b:VCSCommandCommand'
10. Added new automatic variables to command result buffers.
'b:VCSCommandSourceFile'
'b:VCSCommandVCSType'
==============================================================================
8. Known bugs *vcscommand-bugs*
Please let me know if you run across any.
CVSUnedit may, if a file is changed from the repository, provide prompt text
to determine whether the changes should be thrown away. Currently, that text
shows up in the CVS result buffer as information; there is no way for the user
to actually respond to the prompt and the CVS unedit command does nothing. If
this really bothers anyone, please let me know.
VCSVimDiff, when using the original (real) source buffer as one of the diff
buffers, uses some hacks to try to restore the state of the original buffer
when the scratch buffer containing the other version is destroyed. There may
still be bugs in here, depending on many configuration details.
vim:tw=78:ts=8:ft=help

View File

@ -0,0 +1,45 @@
" Vim syntax file
" Language: CVS annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the cvscommand plugin. Originally written by Mathieu
" Clabaut
" License:
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
" deal in the Software without restriction, including without limitation the
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
" sell copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
" IN THE SOFTWARE.
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn match cvsDate /\d\d-...-\d\d/ contained
syn match cvsName /(\S* /hs=s+1,he=e-1 contained nextgroup=cvsDate
syn match cvsVer /^\d\+\(\.\d\+\)\+/ contained nextgroup=cvsName
syn region cvsHead start="^\d\+\.\d\+" end="):" contains=cvsVer,cvsName,cvsDate
if !exists("did_cvsannotate_syntax_inits")
let did_cvsannotate_syntax_inits = 1
hi link cvsDate Comment
hi link cvsName Type
hi link cvsVer Statement
endif
let b:current_syntax="CVSAnnotate"

View File

@ -0,0 +1,44 @@
" Vim syntax file
" Language: git annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
" deal in the Software without restriction, including without limitation the
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
" sell copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
" IN THE SOFTWARE.
if exists("b:current_syntax")
finish
endif
syn region gitName start="(\@<=" end="\( \d\d\d\d-\)\@=" contained
syn match gitCommit /^\^\?\x\+/ contained
syn match gitDate /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d [+-]\d\d\d\d/ contained
syn match gitLineNumber /\d\+)\@=/ contained
syn region gitAnnotation start="^" end=") " oneline keepend contains=gitCommit,gitLineNumber,gitDate,gitName
if !exists("did_gitannotate_syntax_inits")
let did_gitannotate_syntax_inits = 1
hi link gitName Type
hi link gitCommit Statement
hi link gitDate Comment
hi link gitLineNumber Label
endif
let b:current_syntax="gitAnnotate"

View File

@ -0,0 +1,40 @@
" Vim syntax file
" Language: HG annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
" deal in the Software without restriction, including without limitation the
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
" sell copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
" IN THE SOFTWARE.
if exists("b:current_syntax")
finish
endif
syn match hgVer /\d\+/ contained
syn match hgName /^\s*\S\+/ contained
syn match hgHead /^\s*\S\+\s\+\d\+:/ contains=hgVer,hgName
if !exists("did_hgannotate_syntax_inits")
let did_hgannotate_syntax_inits = 1
hi link hgName Type
hi link hgVer Statement
endif
let b:current_syntax="hgAnnotate"

View File

@ -0,0 +1,42 @@
" Vim syntax file
" Language: SVK annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
" deal in the Software without restriction, including without limitation the
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
" sell copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
" IN THE SOFTWARE.
if exists("b:current_syntax")
finish
endif
syn match svkDate /\d\{4}-\d\{1,2}-\d\{1,2}/ skipwhite contained
syn match svkName /(\s*\zs\S\+/ contained nextgroup=svkDate skipwhite
syn match svkVer /^\s*\d\+/ contained nextgroup=svkName skipwhite
syn region svkHead start=/^/ end="):" contains=svkVer,svkName,svkDate oneline
if !exists("did_svkannotate_syntax_inits")
let did_svkannotate_syntax_inits = 1
hi link svkName Type
hi link svkDate Comment
hi link svkVer Statement
endif
let b:current_syntax="svkAnnotate"

View File

@ -0,0 +1,40 @@
" Vim syntax file
" Language: SVN annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
" deal in the Software without restriction, including without limitation the
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
" sell copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
" IN THE SOFTWARE.
if exists("b:current_syntax")
finish
endif
syn match svnName /\S\+/ contained
syn match svnVer /^\s*\zs\d\+/ contained nextgroup=svnName skipwhite
syn match svnHead /^\s*\d\+\s\+\S\+/ contains=svnVer,svnName
if !exists("did_svnannotate_syntax_inits")
let did_svnannotate_syntax_inits = 1
hi link svnName Type
hi link svnVer Statement
endif
let b:current_syntax="svnAnnotate"

View File

@ -0,0 +1,31 @@
" Vim syntax file
" Language: VCS commit file
" Maintainer: Bob Hiestand (bob.hiestand@gmail.com)
" License:
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
" deal in the Software without restriction, including without limitation the
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
" sell copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
" IN THE SOFTWARE.
if exists("b:current_syntax")
finish
endif
syntax region vcsComment start="^VCS: " end="$"
highlight link vcsComment Comment
let b:current_syntax = "vcscommit"

View File

@ -0,0 +1,209 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=3709
* author: Paul Ivanov (http://pirsquared.org)
* github: http://github.com/ivanov/vim-ipython
* demos: http://pirsquared.org/vim-ipython/
* blogpost: http://pirsquared.org/blog/2011/07/28/vim-ipython/
Using this plugin, you can send lines or whole files for IPython to
execute, and also get back object introspection and word completions in
Vim, like what you get with: ``object?<enter>`` and ``object.<tab>`` in
IPython.
The big change from previous versions of ``ipy.vim`` is that it no longer
requires the old brittle ``ipy_vimserver.py`` instantiation, and since
it uses just vim and python, it is platform independent (i.e. works
even on windows, unlike the previous \*nix only solution). The requirements
are IPython 0.11+ with zeromq capabilities, vim compiled with +python.
If you can launch ``ipython qtconsole`` or ``ipython kernel``, and
``:echo has('python')`` returns 1 in vim, you should be good to go.
-----------------
Quickstart Guide:
-----------------
Start ``ipython qtconsole`` [*]_ and copy the connection string.
Source ``ipy.vim`` file, which provides new IPython command::
:source ipy.vim
(or copy it to ~/.vim/ftplugin/python to load automatically)
:IPythonClipboard
(or :IPythonXSelection if you're using X11 without having to copy)
The :IPython command allows you to put the full connection string. For IPython
0.11, it would look like this::
:IPython --existing --shell=41882 --iopub=43286 --stdin=34987 --hb=36697
and for IPython 0.12, like this::
:IPython --existing kernel-85997.json
The ``:IPythonClipboard`` command just uses the ``+`` register to get the
connection string, whereas ``:IPythonXSelection`` uses the ``*`` register.
**NEW in IPython 0.12**!
Since IPython 0.12, you can simply use::
:IPython
without arguments to connect to the most recent IPython session (this is the
same as passing just the ``--existing`` flag to ``ipython qtconsole`` and
``ipython console``.
.. [*] Though the demos above use ``qtconsole``, it is not required
for this workflow, it's just that it was the easiest way to show how to
make use of the new functionality in 0.11 release. Since IPython 0.12, you
can use ``ipython kernel`` to create a kernel and get the connection
string to use for any frontend (including vim-ipython), or use ``ipython
console`` to create a kernel and immediately connect to it using a
terminal-based client. You can even connect to an active IPython Notebook
kernel - just watch for the connection string that gets printed when you
open the notebook, or use the ``%connect_info`` magic to get the
connection string. If you are still using 0.11, you can launch a regular
kernel using ``python -c "from IPython.zmq.ipkernel import main; main()"``
------------------------
Sending lines to IPython
------------------------
Now type out a line and send it to IPython using ``<Ctrl-S>`` from Command mode::
import os
You should see a notification message confirming the line was sent, along
with the input number for the line, like so ``In[1]: import os``.
``<Ctrl-S>`` also works from insert mode, but doesn't show notification,
unless ``monitor_subchannel`` is set to ``True`` (see `vim-ipython 'shell'`_,
below)
It also works blockwise in Visual Mode. Select and send these lines using
``<Ctrl-S>``::
import this,math # secret decoder ring
a,b,c,d,e,f,g,h,i = range(1,10)
code =(c,a,d,a,e,i,)
msg = '...jrer nyy frag sebz Ivz.\nIvz+VClguba=%fyl '+this.s.split()[g]
decode=lambda x:"\n"+"".join([this.d.get(c,c) for c in x])+"!"
format=lambda x:'These lines:\n '+'\n '.join([l for l in x.splitlines()])
secret_decoder = lambda a,b: format(a)+decode(msg)%str(b)[:-1]
'%d'*len(code)%code == str(int(math.pi*1e5))
Then, go to the qtconsole and run this line::
print secret_decoder(_i,_)
You can also send whole files to IPython's ``%run`` magic using ``<F5>``.
**NEW in IPython 0.12**!
If you're trying to do run code fragments that have leading whitespace, use
``<Alt-S>`` instead - it will dedent a single line, and remove the leading
whitespace of the first line from all lines in a visual mode selection.
-------------------------------
IPython's object? Functionality
-------------------------------
If you're using gvim, mouse-over a variable to see IPython's ``?`` equivalent.
If you're using vim from a terminal, or want to copy something from the
docstring, type ``<leader>d``. ``<leader>`` is usually ``\`` (the backslash
key). This will open a quickpreview window, which can be closed by hitting
``q`` or ``<escape>``.
--------------------------------------
IPython's tab-completion Functionality
--------------------------------------
vim-ipython activates a 'completefunc' that queries IPython.
A completefunc is activated using ``Ctrl-X Ctrl-U`` in Insert Mode (vim
default). You can combine this functionality with SuperTab to get tab
completion.
-------------------
vim-ipython 'shell'
-------------------
**NEW since IPython 0.11**!
By monitoring km.sub_channel, we can recreate what messages were sent to
IPython, and what IPython sends back in response.
``monitor_subchannel`` is a parameter that sets whether this 'shell' should
updated on every sent command (default: True).
If at any later time you wish to bring this shell up, including if you've set
``monitor_subchannel=False``, hit ``<leader>s``.
-------
Options
-------
You can change these at the top of the ipy.vim::
reselect = False # reselect lines after sending from Visual mode
show_execution_count = True # wait to get numbers for In[43]: feedback?
monitor_subchannel = True # update vim-ipython 'shell' on every send?
run_flags= "-i" # flags to for IPython's run magic when using <F5>
**Disabling default mappings**
In your own ``.vimrc``, if you don't like the mappings provided by default,
you can define a variable ``let g:ipy_perform_mappings=0`` which will prevent
vim-ipython from defining any of the default mappings.
---------------
Current issues:
---------------
- For now, vim-ipython only connects to an ipython session in progress.
- The ipdb integration is not yet re-implemented.
- If you're running inside ``screen``, read about the ``<CTRL-S>`` issue `here
<http://munkymorgy.blogspot.com/2008/07/screen-ctrl-s-bug.html&gt;`_, and add
this line to your ``.bashrc`` to fix it::
stty stop undef # to unmap ctrl-s
- In vim, if you're getting ``ImportError: No module named
IPython.zmq.blockingkernelmanager`` but are able to import it in regular
python, **either**
1. your ``sys.path`` in vim differs from the ``sys.path`` in regular python.
Try running these two lines, and comparing their output files::
$ vim -c 'py import vim, sys; vim.current.buffer.append(sys.path)' -c ':wq vim_syspath'
$ python -c "import sys; f=file('python_syspath','w'); f.write('\n'.join(sys.path)); f.close()"
**or**
2. your vim is compiled against a different python than you are launching. See
if there's a difference between ::
$ vim -c ':py import os; print os.__file__' -c ':q'
$ python -c 'import os; print os.__file__'
- For vim inside a terminal, using the arrow keys won't work inside a
documentation buffer, because the mapping for ``<Esc>`` overlaps with
``^[OA`` and so on, and we use ``<Esc>`` as a quick way of closing the
documentation preview window. If you want go without this quick close
functionality and want to use the arrow keys instead, look for instructions
starting with "Known issue: to enable the use of arrow keys..." in the
``get_doc_buffer`` function.
- @fholgado's update to ``minibufexpl.vim`` that is up on GitHub will always
put the cursor in the minibuf after sending a command when
``monitor_subchannel`` is set. This is a bug in minibufexpl.vim and the workaround
is described in vim-ipython issue #7.
----------------------------
Thanks and Bug Participation
----------------------------
* @MinRK for guiding me through the IPython kernel manager protocol.
* @nakamuray and @tcheneau for reporting and providing a fix for when vim is
compiled without a gui (#1)
* @unpingco for reporting Windows bugs (#3,#4), providing better multiline
dedenting (#15), and suggesting that a resized vim-ipython shell stays
resized (#16).
* @simon-b for terminal vim arrow key issue (#5)
* @jorgesca and @kwgoodman for shell update problems (#6)
* @zeekay for easily allowing custom mappings (#9)
* @minrk for support of connection_file-based IPython connection (#13)
* @jorgesca for reporting the lack of profile handling capability (#14)
* @enzbang for removing mapping that's not currently functional (#17)
* @ogrisel for fixing documentation typo (#19)

View File

@ -0,0 +1,212 @@
###########
vim-ipython
###########
A two-way integration between Vim and IPython 0.11+
* author: Paul Ivanov (http://pirsquared.org)
* github: http://github.com/ivanov/vim-ipython
* demos: http://pirsquared.org/vim-ipython/
* blogpost: http://pirsquared.org/blog/2011/07/28/vim-ipython/
Using this plugin, you can send lines or whole files for IPython to
execute, and also get back object introspection and word completions in
Vim, like what you get with: ``object?<enter>`` and ``object.<tab>`` in
IPython.
The big change from previous versions of ``ipy.vim`` is that it no longer
requires the old brittle ``ipy_vimserver.py`` instantiation, and since
it uses just vim and python, it is platform independent (i.e. works
even on windows, unlike the previous \*nix only solution). The requirements
are IPython 0.11+ with zeromq capabilities, vim compiled with +python.
If you can launch ``ipython qtconsole`` or ``ipython kernel``, and
``:echo has('python')`` returns 1 in vim, you should be good to go.
-----------------
Quickstart Guide:
-----------------
Start ``ipython qtconsole`` [*]_ and copy the connection string.
Source ``ipy.vim`` file, which provides new IPython command::
:source ipy.vim
(or copy it to ~/.vim/ftplugin/python to load automatically)
:IPythonClipboard
(or :IPythonXSelection if you're using X11 without having to copy)
The :IPython command allows you to put the full connection string. For IPython
0.11, it would look like this::
:IPython --existing --shell=41882 --iopub=43286 --stdin=34987 --hb=36697
and for IPython 0.12, like this::
:IPython --existing kernel-85997.json
The ``:IPythonClipboard`` command just uses the ``+`` register to get the
connection string, whereas ``:IPythonXSelection`` uses the ``*`` register.
**NEW in IPython 0.12**!
Since IPython 0.12, you can simply use::
:IPython
without arguments to connect to the most recent IPython session (this is the
same as passing just the ``--existing`` flag to ``ipython qtconsole`` and
``ipython console``.
.. [*] Though the demos above use ``qtconsole``, it is not required
for this workflow, it's just that it was the easiest way to show how to
make use of the new functionality in 0.11 release. Since IPython 0.12, you
can use ``ipython kernel`` to create a kernel and get the connection
string to use for any frontend (including vim-ipython), or use ``ipython
console`` to create a kernel and immediately connect to it using a
terminal-based client. You can even connect to an active IPython Notebook
kernel - just watch for the connection string that gets printed when you
open the notebook, or use the ``%connect_info`` magic to get the
connection string. If you are still using 0.11, you can launch a regular
kernel using ``python -c "from IPython.zmq.ipkernel import main; main()"``
------------------------
Sending lines to IPython
------------------------
Now type out a line and send it to IPython using ``<Ctrl-S>`` from Command mode::
import os
You should see a notification message confirming the line was sent, along
with the input number for the line, like so ``In[1]: import os``.
``<Ctrl-S>`` also works from insert mode, but doesn't show notification,
unless ``monitor_subchannel`` is set to ``True`` (see `vim-ipython 'shell'`_,
below)
It also works blockwise in Visual Mode. Select and send these lines using
``<Ctrl-S>``::
import this,math # secret decoder ring
a,b,c,d,e,f,g,h,i = range(1,10)
code =(c,a,d,a,e,i,)
msg = '...jrer nyy frag sebz Ivz.\nIvz+VClguba=%fyl '+this.s.split()[g]
decode=lambda x:"\n"+"".join([this.d.get(c,c) for c in x])+"!"
format=lambda x:'These lines:\n '+'\n '.join([l for l in x.splitlines()])
secret_decoder = lambda a,b: format(a)+decode(msg)%str(b)[:-1]
'%d'*len(code)%code == str(int(math.pi*1e5))
Then, go to the qtconsole and run this line::
print secret_decoder(_i,_)
You can also send whole files to IPython's ``%run`` magic using ``<F5>``.
**NEW in IPython 0.12**!
If you're trying to do run code fragments that have leading whitespace, use
``<Alt-S>`` instead - it will dedent a single line, and remove the leading
whitespace of the first line from all lines in a visual mode selection.
-------------------------------
IPython's object? Functionality
-------------------------------
If you're using gvim, mouse-over a variable to see IPython's ``?`` equivalent.
If you're using vim from a terminal, or want to copy something from the
docstring, type ``<leader>d``. ``<leader>`` is usually ``\`` (the backslash
key). This will open a quickpreview window, which can be closed by hitting
``q`` or ``<escape>``.
--------------------------------------
IPython's tab-completion Functionality
--------------------------------------
vim-ipython activates a 'completefunc' that queries IPython.
A completefunc is activated using ``Ctrl-X Ctrl-U`` in Insert Mode (vim
default). You can combine this functionality with SuperTab to get tab
completion.
-------------------
vim-ipython 'shell'
-------------------
**NEW since IPython 0.11**!
By monitoring km.sub_channel, we can recreate what messages were sent to
IPython, and what IPython sends back in response.
``monitor_subchannel`` is a parameter that sets whether this 'shell' should
updated on every sent command (default: True).
If at any later time you wish to bring this shell up, including if you've set
``monitor_subchannel=False``, hit ``<leader>s``.
-------
Options
-------
You can change these at the top of the ipy.vim::
reselect = False # reselect lines after sending from Visual mode
show_execution_count = True # wait to get numbers for In[43]: feedback?
monitor_subchannel = True # update vim-ipython 'shell' on every send?
run_flags= "-i" # flags to for IPython's run magic when using <F5>
**Disabling default mappings**
In your own ``.vimrc``, if you don't like the mappings provided by default,
you can define a variable ``let g:ipy_perform_mappings=0`` which will prevent
vim-ipython from defining any of the default mappings.
---------------
Current issues:
---------------
- For now, vim-ipython only connects to an ipython session in progress.
- The ipdb integration is not yet re-implemented.
- If you're running inside ``screen``, read about the ``<CTRL-S>`` issue `here
<http://munkymorgy.blogspot.com/2008/07/screen-ctrl-s-bug.html>`_, and add
this line to your ``.bashrc`` to fix it::
stty stop undef # to unmap ctrl-s
- In vim, if you're getting ``ImportError: No module named
IPython.zmq.blockingkernelmanager`` but are able to import it in regular
python, **either**
1. your ``sys.path`` in vim differs from the ``sys.path`` in regular python.
Try running these two lines, and comparing their output files::
$ vim -c 'py import vim, sys; vim.current.buffer.append(sys.path)' -c ':wq vim_syspath'
$ python -c "import sys; f=file('python_syspath','w'); f.write('\n'.join(sys.path)); f.close()"
**or**
2. your vim is compiled against a different python than you are launching. See
if there's a difference between ::
$ vim -c ':py import os; print os.__file__' -c ':q'
$ python -c 'import os; print os.__file__'
- For vim inside a terminal, using the arrow keys won't work inside a
documentation buffer, because the mapping for ``<Esc>`` overlaps with
``^[OA`` and so on, and we use ``<Esc>`` as a quick way of closing the
documentation preview window. If you want go without this quick close
functionality and want to use the arrow keys instead, look for instructions
starting with "Known issue: to enable the use of arrow keys..." in the
``get_doc_buffer`` function.
- @fholgado's update to ``minibufexpl.vim`` that is up on GitHub will always
put the cursor in the minibuf after sending a command when
``monitor_subchannel`` is set. This is a bug in minibufexpl.vim and the workaround
is described in vim-ipython issue #7.
----------------------------
Thanks and Bug Participation
----------------------------
* @MinRK for guiding me through the IPython kernel manager protocol.
* @nakamuray and @tcheneau for reporting and providing a fix for when vim is
compiled without a gui (#1)
* @unpingco for reporting Windows bugs (#3,#4), providing better multiline
dedenting (#15), and suggesting that a resized vim-ipython shell stays
resized (#16).
* @simon-b for terminal vim arrow key issue (#5)
* @jorgesca and @kwgoodman for shell update problems (#6)
* @zeekay for easily allowing custom mappings (#9)
* @minrk for support of connection_file-based IPython connection (#13)
* @jorgesca for reporting the lack of profile handling capability (#14)
* @enzbang for removing mapping that's not currently functional (#17)
* @ogrisel for fixing documentation typo (#19)

View File

@ -0,0 +1,521 @@
" Vim integration with IPython 0.11+
"
" A two-way integration between Vim and IPython.
"
" Using this plugin, you can send lines or whole files for IPython to execute,
" and also get back object introspection and word completions in Vim, like
" what you get with: object?<enter> object.<tab> in IPython
"
" -----------------
" Quickstart Guide:
" -----------------
" Start ipython qtconsole and copy the connection string.
" Source this file, which provides new IPython command
" :source ipy.vim
" :IPythonClipboard
" (or :IPythonXSelection if you're using X11 without having to copy)
"
" written by Paul Ivanov (http://pirsquared.org)
python << EOF
reselect = False # reselect lines after sending from Visual mode
show_execution_count = True # wait to get numbers for In[43]: feedback?
monitor_subchannel = True # update vim-ipython 'shell' on every send?
run_flags= "-i" # flags to for IPython's run magic when using <F5>
import vim
import sys
# get around unicode problems when interfacing with vim
vim_encoding=vim.eval('&encoding') or 'utf-8'
try:
sys.stdout.flush
except AttributeError:
# IPython complains if stderr and stdout don't have flush
# this is fixed in newer version of Vim
class WithFlush(object):
def __init__(self,noflush):
self.write=noflush.write
self.writelines=noflush.writelines
def flush(self):pass
sys.stdout = WithFlush(sys.stdout)
sys.stderr = WithFlush(sys.stderr)
ip = '127.0.0.1'
try:
km
except NameError:
km = None
def km_from_string(s=''):
"""create kernel manager from IPKernelApp string
such as '--shell=47378 --iopub=39859 --stdin=36778 --hb=52668' for IPython 0.11
or just 'kernel-12345.json' for IPython 0.12
"""
from os.path import join as pjoin
from IPython.zmq.blockingkernelmanager import BlockingKernelManager, Empty
from IPython.config.loader import KeyValueConfigLoader
from IPython.zmq.kernelapp import kernel_aliases
global km,send,Empty
s = s.replace('--existing', '')
if 'connection_file' in BlockingKernelManager.class_trait_names():
from IPython.lib.kernel import find_connection_file
# 0.12 uses files instead of a collection of ports
# include default IPython search path
# filefind also allows for absolute paths, in which case the search
# is ignored
try:
# XXX: the following approach will be brittle, depending on what
# connection strings will end up looking like in the future, and
# whether or not they are allowed to have spaces. I'll have to sync
# up with the IPython team to address these issues -pi
if '--profile' in s:
k,p = s.split('--profile')
k = k.lstrip().rstrip() # kernel part of the string
p = p.lstrip().rstrip() # profile part of the string
fullpath = find_connection_file(k,p)
else:
fullpath = find_connection_file(s.lstrip().rstrip())
except IOError,e:
echo(":IPython " + s + " failed", "Info")
echo("^-- failed '" + s + "' not found", "Error")
return
km = BlockingKernelManager(connection_file = fullpath)
km.load_connection_file()
else:
if s == '':
echo(":IPython 0.11 requires the full connection string")
return
loader = KeyValueConfigLoader(s.split(), aliases=kernel_aliases)
cfg = loader.load_config()['KernelApp']
try:
km = BlockingKernelManager(
shell_address=(ip, cfg['shell_port']),
sub_address=(ip, cfg['iopub_port']),
stdin_address=(ip, cfg['stdin_port']),
hb_address=(ip, cfg['hb_port']))
except KeyError,e:
echo(":IPython " +s + " failed", "Info")
echo("^-- failed --"+e.message.replace('_port','')+" not specified", "Error")
return
km.start_channels()
send = km.shell_channel.execute
return km
def echo(arg,style="Question"):
try:
vim.command("echohl %s" % style)
vim.command("echom \"%s\"" % arg.replace('\"','\\\"'))
vim.command("echohl None")
except vim.error:
print "-- %s" % arg
def disconnect():
"disconnect kernel manager"
# XXX: make a prompt here if this km owns the kernel
pass
def get_doc(word):
if km is None:
return ["Not connected to IPython, cannot query \"%s\"" %word]
msg_id = km.shell_channel.object_info(word)
doc = get_doc_msg(msg_id)
# get around unicode problems when interfacing with vim
return [d.encode(vim_encoding) for d in doc]
import re
# from http://serverfault.com/questions/71285/in-centos-4-4-how-can-i-strip-escape-sequences-from-a-text-file
strip = re.compile('\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]')
def strip_color_escapes(s):
return strip.sub('',s)
def get_doc_msg(msg_id):
n = 13 # longest field name (empirically)
b=[]
try:
content = get_child_msg(msg_id)['content']
except Empty:
# timeout occurred
return ["no reply from IPython kernel"]
if not content['found']:
return b
for field in ['type_name','base_class','string_form','namespace',
'file','length','definition','source','docstring']:
c = content.get(field,None)
if c:
if field in ['definition']:
c = strip_color_escapes(c).rstrip()
s = field.replace('_',' ').title()+':'
s = s.ljust(n)
if c.find('\n')==-1:
b.append(s+c)
else:
b.append(s)
b.extend(c.splitlines())
return b
def get_doc_buffer(level=0):
# empty string in case vim.eval return None
word = vim.eval('expand("<cfile>")') or ''
doc = get_doc(word)
if len(doc) ==0:
echo(word+" not found","Error")
return
# close any currently open preview windows
vim.command('pcl')
# documentation buffer name is same as the query made to ipython
vim.command('new '+word)
vim.command('setlocal pvw modifiable noro')
# doc window quick quit keys: 'q' and 'escape'
vim.command('map <buffer> q :q<CR>')
# Known issue: to enable the use of arrow keys inside the terminal when
# viewing the documentation, comment out the next line
vim.command('map <buffer> <Esc> :q<CR>')
# and uncomment this line (which will work if you have a timoutlen set)
#vim.command('map <buffer> <Esc><Esc> :q<CR>')
b = vim.current.buffer
b[:] = None
b[:] = doc
vim.command('setlocal nomodified bufhidden=wipe')
#vim.command('setlocal previewwindow nomodifiable nomodified ro')
#vim.command('set previewheight=%d'%len(b))# go to previous window
vim.command('resize %d'%len(b))
#vim.command('pcl')
#vim.command('pedit doc')
#vim.command('normal ') # go to previous window
def update_subchannel_msgs(debug=False):
msgs = km.sub_channel.get_msgs()
if debug:
#try:
# vim.command("b debug_msgs")
#except vim.error:
# vim.command("new debug_msgs")
#finally:
db = vim.current.buffer
else:
db = []
b = vim.current.buffer
startedin_vimipython = vim.eval('@%')=='vim-ipython'
if not startedin_vimipython:
# switch to preview window
vim.command(
"try"
"|silent! wincmd P"
"|catch /^Vim\%((\a\+)\)\=:E441/"
"|silent pedit +set\ ma vim-ipython"
"|silent! wincmd P"
"|endtry")
# if the current window is called 'vim-ipython'
if vim.eval('@%')=='vim-ipython':
# set the preview window height to the current height
vim.command("set pvh=" + vim.eval('winheight(0)'))
else:
# close preview window, it was something other than 'vim-ipython'
vim.command("pcl")
vim.command("silent pedit +set\ ma vim-ipython")
vim.command("wincmd P") #switch to preview window
# subchannel window quick quit key 'q'
vim.command('map <buffer> q :q<CR>')
vim.command("set bufhidden=hide buftype=nofile ft=python")
#syntax highlighting for python prompt
# QtConsole In[] is blue, but I prefer the oldschool green
# since it makes the vim-ipython 'shell' look like the holidays!
#vim.command("hi Blue ctermfg=Blue guifg=Blue")
vim.command("hi Green ctermfg=Green guifg=Green")
vim.command("hi Red ctermfg=Red guifg=Red")
vim.command("syn keyword Green 'In\ []:'")
vim.command("syn match Green /^In \[[0-9]*\]\:/")
vim.command("syn match Red /^Out\[[0-9]*\]\:/")
b = vim.current.buffer
for m in msgs:
#db.append(str(m).splitlines())
s = ''
if 'msg_type' not in m['header']:
# debug information
#echo('skipping a message on sub_channel','WarningMsg')
#echo(str(m))
continue
elif m['header']['msg_type'] == 'status':
continue
elif m['header']['msg_type'] == 'stream':
s = strip_color_escapes(m['content']['data'])
elif m['header']['msg_type'] == 'pyout':
s = "Out[%d]: " % m['content']['execution_count']
s += m['content']['data']['text/plain']
elif m['header']['msg_type'] == 'pyin':
# TODO: the next line allows us to resend a line to ipython if
# %doctest_mode is on. In the future, IPython will send the
# execution_count on subchannel, so this will need to be updated
# once that happens
if 'execution_count' in m['content']:
s = "\nIn [%d]: "% m['content']['execution_count']
else:
s = "\nIn [00]: "
s += m['content']['code'].strip()
elif m['header']['msg_type'] == 'pyerr':
c = m['content']
s = "\n".join(map(strip_color_escapes,c['traceback']))
s += c['ename'] + ":" + c['evalue']
if s.find('\n') == -1:
# somewhat ugly unicode workaround from
# http://vim.1045645.n5.nabble.com/Limitations-of-vim-python-interface-with-respect-to-character-encodings-td1223881.html
if isinstance(s,unicode):
s=s.encode(vim_encoding)
b.append(s)
else:
try:
b.append(s.splitlines())
except:
b.append([l.encode(vim_encoding) for l in s.splitlines()])
# make a newline so we can just start typing there
if b[-1] != '':
b.append([''])
vim.command('normal G') # go to the end of the file
if not startedin_vimipython:
vim.command('normal p') # go back to where you were
def get_child_msg(msg_id):
# XXX: message handling should be split into its own process in the future
while True:
# get_msg will raise with Empty exception if no messages arrive in 1 second
m= km.shell_channel.get_msg(timeout=1)
if m['parent_header']['msg_id'] == msg_id:
break
else:
#got a message, but not the one we were looking for
echo('skipping a message on shell_channel','WarningMsg')
return m
def print_prompt(prompt,msg_id=None):
"""Print In[] or In[42] style messages"""
global show_execution_count
if show_execution_count and msg_id:
# wait to get message back from kernel
try:
child = get_child_msg(msg_id)
count = child['content']['execution_count']
echo("In[%d]: %s" %(count,prompt))
except Empty:
echo("In[]: %s (no reply from IPython kernel)" % prompt)
else:
echo("In[]: %s" % prompt)
def with_subchannel(f,*args):
"conditionally monitor subchannel"
def f_with_update(*args):
try:
f(*args)
if monitor_subchannel:
update_subchannel_msgs()
except AttributeError: #if km is None
echo("not connected to IPython", 'Error')
return f_with_update
@with_subchannel
def run_this_file():
msg_id = send('run %s %s' % (run_flags, repr(vim.current.buffer.name),))
print_prompt("In[]: run %s %s" % (run_flags, repr(vim.current.buffer.name)),msg_id)
@with_subchannel
def run_this_line():
msg_id = send(vim.current.line)
print_prompt(vim.current.line, msg_id)
@with_subchannel
def run_command(cmd):
msg_id = send(cmd)
print_prompt(cmd, msg_id)
if monitor_subchannel:
update_subchannel_msgs()
@with_subchannel
def run_these_lines():
r = vim.current.range
lines = "\n".join(vim.current.buffer[r.start:r.end+1])
msg_id = send(lines)
#alternative way of doing this in more recent versions of ipython
#but %paste only works on the local machine
#vim.command("\"*yy")
#send("'%paste')")
#reselect the previously highlighted block
vim.command("normal gv")
if not reselect:
vim.command("normal ")
#vim lines start with 1
#print "lines %d-%d sent to ipython"% (r.start+1,r.end+1)
prompt = "lines %d-%d "% (r.start+1,r.end+1)
print_prompt(prompt,msg_id)
def dedent_run_this_line():
vim.command("left")
run_this_line()
vim.command("silent undo")
def dedent_run_these_lines():
r = vim.current.range
shiftwidth = vim.eval('&shiftwidth')
count = int(vim.eval('indent(%d+1)/%s' % (r.start,shiftwidth)))
vim.command("'<,'>" + "<"*count)
run_these_lines()
vim.command("silent undo")
#def set_this_line():
# # not sure if there's a way to do this, since we have multiple clients
# send("get_ipython().shell.set_next_input(\'%s\')" % vim.current.line.replace("\'","\\\'"))
# #print "line \'%s\' set at ipython prompt"% vim.current.line
# echo("line \'%s\' set at ipython prompt"% vim.current.line,'Statement')
def toggle_reselect():
global reselect
reselect=not reselect
print "F9 will%sreselect lines after sending to ipython"% (reselect and " " or " not ")
#def set_breakpoint():
# send("__IP.InteractiveTB.pdb.set_break('%s',%d)" % (vim.current.buffer.name,
# vim.current.window.cursor[0]))
# print "set breakpoint in %s:%d"% (vim.current.buffer.name,
# vim.current.window.cursor[0])
#
#def clear_breakpoint():
# send("__IP.InteractiveTB.pdb.clear_break('%s',%d)" % (vim.current.buffer.name,
# vim.current.window.cursor[0]))
# print "clearing breakpoint in %s:%d" % (vim.current.buffer.name,
# vim.current.window.cursor[0])
#
#def clear_all_breakpoints():
# send("__IP.InteractiveTB.pdb.clear_all_breaks()");
# print "clearing all breakpoints"
#
#def run_this_file_pdb():
# send(' __IP.InteractiveTB.pdb.run(\'execfile("%s")\')' % (vim.current.buffer.name,))
# #send('run -d %s' % (vim.current.buffer.name,))
# echo("In[]: run -d %s (using pdb)" % vim.current.buffer.name)
EOF
fun! <SID>toggle_send_on_save()
if exists("s:ssos") && s:ssos == 0
let s:ssos = 1
au BufWritePost *.py :py run_this_file()
echo "Autosend On"
else
let s:ssos = 0
au! BufWritePost *.py
echo "Autosend Off"
endif
endfun
" Allow custom mappings
if !exists('g:ipy_perform_mappings')
let g:ipy_perform_mappings = 1
endif
if g:ipy_perform_mappings != 0
map <silent> <F5> :python run_this_file()<CR>
map <silent> <S-F5> :python run_this_line()<CR>
map <silent> <F9> :python run_these_lines()<CR>
map <silent> <leader>d :py get_doc_buffer()<CR>
map <silent> <leader>s :py update_subchannel_msgs(); echo("vim-ipython shell updated",'Operator')<CR>
map <silent> <S-F9> :python toggle_reselect()<CR>
"map <silent> <C-F6> :python send('%pdb')<CR>
"map <silent> <F6> :python set_breakpoint()<CR>
"map <silent> <s-F6> :python clear_breakpoint()<CR>
"map <silent> <F7> :python run_this_file_pdb()<CR>
"map <silent> <s-F7> :python clear_all_breaks()<CR>
imap <C-F5> <C-O><F5>
imap <S-F5> <C-O><S-F5>
imap <silent> <F5> <C-O><F5>
map <C-F5> :call <SID>toggle_send_on_save()<CR>
"" Example of how to quickly clear the current plot with a keystroke
"map <silent> <F12> :python run_command("plt.clf()")<cr>
"" Example of how to quickly close all figures with a keystroke
"map <silent> <F11> :python run_command("plt.close('all')")<cr>
"pi custom
map <silent> <C-Return> :python run_this_file()<CR>
map <silent> <C-s> :python run_this_line()<CR>
imap <silent> <C-s> <C-O>:python run_this_line()<CR>
map <silent> <M-s> :python dedent_run_this_line()<CR>
vmap <silent> <C-S> :python run_these_lines()<CR>
vmap <silent> <M-s> :python dedent_run_these_lines()<CR>
map <silent> <M-c> I#<ESC>
vmap <silent> <M-c> I#<ESC>
map <silent> <M-C> :s/^\([ \t]*\)#/\1/<CR>
vmap <silent> <M-C> :s/^\([ \t]*\)#/\1/<CR>
endif
command! -nargs=* IPython :py km_from_string("<args>")
command! -nargs=0 IPythonClipboard :py km_from_string(vim.eval('@+'))
command! -nargs=0 IPythonXSelection :py km_from_string(vim.eval('@*'))
function! IPythonBalloonExpr()
python << endpython
word = vim.eval('v:beval_text')
reply = get_doc(word)
vim.command("let l:doc = %s"% reply)
endpython
return l:doc
endfunction
if has('balloon_eval')
set bexpr=IPythonBalloonExpr()
set ballooneval
endif
fun! CompleteIPython(findstart, base)
if a:findstart
" locate the start of the word
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start-1] =~ '\k\|\.' "keyword
let start -= 1
endwhile
echo start
return start
else
" find months matching with "a:base"
let res = []
python << endpython
base = vim.eval("a:base")
findstart = vim.eval("a:findstart")
msg_id = km.shell_channel.complete(base, vim.current.line, vim.eval("col('.')"))
try:
m = get_child_msg(msg_id)
matches = m['content']['matches']
matches.insert(0,base) # the "no completion" version
# we need to be careful with unicode, because we can have unicode
# completions for filenames (for the %run magic, for example). So the next
# line will fail on those:
#completions= [str(u) for u in matches]
# because str() won't work for non-ascii characters
# and we also have problems with unicode in vim, hence the following:
completions = [s.encode(vim_encoding) for s in matches]
except Empty:
echo("no reply from IPython kernel")
completions=['']
## Additionally, we have no good way of communicating lists to vim, so we have
## to turn in into one long string, which can be problematic if e.g. the
## completions contain quotes. The next line will not work if some filenames
## contain quotes - but if that's the case, the user's just asking for
## it, right?
#completions = '["'+ '", "'.join(completions)+'"]'
#vim.command("let completions = %s" % completions)
## An alternative for the above, which will insert matches one at a time, so
## if there's a problem with turning a match into a string, it'll just not
## include the problematic match, instead of not including anything. There's a
## bit more indirection here, but I think it's worth it
for c in completions:
vim.command('call add(res,"'+c+'")')
endpython
"call extend(res,completions)
return res
endif
endfun
set completefunc=CompleteIPython

View File

@ -0,0 +1,166 @@
=============================
Simple Vim templates plugin
=============================
:Author: Adrian Perez <aperez@igalia.com>
This is a simple plugin for Vim that will allow you to have a set of
templates for certain file types. It is useful to add boilerplate code
like guards in C/C++ headers, or license disclaimers.
Installation
============
The easiest way to install the plugin is to install it as a bundle.
For example, using Pathogen__:
1. Get and install `pathogen.vim <_Pathogen>`__. You can skip this step
if you already have it installed.
2. ``cd ~/.vim/bundle``
3. ``git clone git://github.com/aperezdc/vim-template.git``
__ https://github.com/tpope/vim-pathogen
Bundle installs are known to work fine also when using Vundle__. Other
bundle managers are expected to work as well.
__ https://github.com/gmarik/vundle
Updating
========
Manually
--------
In order to update the plugin, go to its bundle directory and use
Git to update it:
1. ``cd ~/.vim/bundle/vim-template``
2. ``git pull``
With Vundle
-----------
Use the ``:BundleUpdate`` command provided by Vundle, for example invoking
Vim like this::
% vim +BundleUpdate
Configuration
=============
In your vimrc you can put:
* ``let g:templates_plugin_loaded = 1`` to skip loading of this plugin.
* ``let g:templates_no_autocmd = 1`` to disable automatic insertion of
template in new files.
* ``let g:templates_directory = '/path/to/directory'`` to specify a directory
from where to search for additional global templates. See `template search
order`_ below for more details. This can also be a list of paths.
* ``let g:templates_name_prefix = '.vimtemplate.'`` to change the name of the
template files that are searched.
* ``let g:templates_global_name_prefix = 'template:'`` to change the prefix of the
templates in the global template directory.
* ``let g:templates_debug = 1`` to have vim-template output debug information
* ``let g:templates_fuzzy_start = 1`` to be able to name templates with
implicit fuzzy matching at the start of a template name. For example a
template file named ``template:.c`` would match ``test.cpp``.
* ``let g:templates_tr_in = [ '.', '_', '?' ]`` and
``let g:templates_tr_out = [ '\.', '.*', '\?' ]`` would allow you to change
how template names are interpretted as regular expressions for matching file
names. This might be helpful if hacking on a windows box where ``*`` is not
allowed in file names. The above configuration, for example, treates
underscores ``_`` as the typical regex wildcard ``.*``.
* ``let g:templates_no_builtin_templates = 1`` to disable usage of the
built-in templates. See `template search order`_ below for more details.
Usage
=====
There are a number of options to use a template:
* Create a new file giving it a name. The suffix will be used to determine
which template to use. E.g::
$ vim foo.c
* In a buffer, use ``:Template *.foo`` to load the template that would be
loaded for file matching the pattern ``*.foo``. E.g. from within Vim::
:Template *.c
Template search order
---------------------
The algorithm to search for templates works like this:
1. A file named ``.vim-template:<pattern>`` in the current directory. If not
found, goto *(2)*. If there are multiple template files that match a given
suffix in the *same* directory, the one that is most specific is used.
2. Go up a directory and goto *(1)*, if not possible, goto *(3)*.
3. Try to use the ``=template=<pattern>`` file from the directory specified
using the ``g:templates_directory`` option (only if the option is defined
and the directory exists).
3. Try to use the ``=template=<pattern>`` file supplied with the plugin (only
if ``g:templates_no_builtin_templates`` was not defined).
Variables in templates
----------------------
The following variables will be expanded in templates:
``%DAY%``, ``%YEAR%``, ``%MONTH%``
Numerical day of the month, year and month.
``%DATE%``
Date in ``YYYY-mm-dd`` format
``%TIME%``
Time in ``HH:MM`` format
``%FDATE%``
Full date (date + time), in ``YYYY-mm-dd HH:MM`` format.
``%FILE%``
File name, without extension.
``%FFILE%``
File name, with extension.
``%EXT%``
File extension.
``%MAIL%``
Current user's e-mail address. May be overriden by defining ``g:email``.
``%USER%``
Current logged-in user name. May be overriden by defining ``g:username``.
``%HOST%``
Host name.
``%GUARD%``
A string with alphanumeric characters and underscores, suitable for use
in proprocessor guards for C/C++/Objective-C header files.
``%CLASS%``
File name, without extension, and the first character of every word is
capital
``%MACROCLASS%``
File name, without extension, and all characters are capitals.
``%CAMELCLASS%``
File name, without extension, the first character of every word is capital,
and all underscores are removed.
``%HERE%``
Expands to nothing, but ensures that the cursor will be placed in its
position after expanding the template.

View File

@ -0,0 +1,466 @@
"
" Template system for Vim
"
" Copyright (C) 2012 Adrian Perez de Castro <aperez@igalia.com>
" Copyright (C) 2005 Adrian Perez de Castro <the.lightman@gmail.com>
"
" Distributed under terms of the MIT license.
"
if exists("g:templates_plugin_loaded")
finish
endif
let g:templates_plugin_loaded = 1
if !exists('g:templates_name_prefix')
let g:templates_name_prefix = ".vim-template:"
endif
if !exists('g:templates_global_name_prefix')
let g:templates_global_name_prefix = "=template="
endif
if !exists('g:templates_debug')
let g:templates_debug = 0
endif
if !exists('g:templates_tr_in')
let g:templates_tr_in = [ '.', '*', '?' ]
endif
if !exists('g:templates_tr_out')
let g:templates_tr_out = [ '\.', '.*', '\?' ]
endif
if !exists('g:templates_fuzzy_start')
let g:templates_fuzzy_start = 1
endif
if !exists('g:templates_directory')
let g:templates_directory = []
elseif type(g:templates_directory) == type('')
" Convert string value to a list with one element.
let s:tmp = g:templates_directory
unlet g:templates_directory
let g:templates_directory = [ s:tmp ]
unlet s:tmp
endif
if !exists('g:templates_no_builtin_templates')
let g:templates_no_builtin_templates = 0
endif
" Put template system autocommands in their own group. {{{1
if !exists('g:templates_no_autocmd')
let g:templates_no_autocmd = 0
endif
if !g:templates_no_autocmd
augroup Templating
autocmd!
autocmd BufNewFile * call <SID>TLoad()
augroup END
endif
function <SID>Debug(mesg)
if g:templates_debug
echom(a:mesg)
endif
endfunction
" normalize the path
" replace the windows path sep \ with /
function <SID>NormalizePath(path)
return substitute(a:path, "\\", "/", "g")
endfunction
" Template searching. {{{1
" Returns a string containing the path of the parent directory of the given
" path. Works like dirname(3). It also simplifies the given path.
function <SID>DirName(path)
let l:tmp = <SID>NormalizePath(a:path)
return substitute(l:tmp, "[^/][^/]*/*$", "", "")
endfunction
" Default templates directory
let s:default_template_dir = <SID>DirName(<SID>DirName(expand("<sfile>"))) . "templates"
" Find the target template in windows
"
" In windows while we clone the symbol link from github
" it will turn to normal file, so we use this function
" to figure out the destination file
function <SID>TFindLink(path, template)
if !filereadable(a:path . a:template)
return a:template
endif
let l:content = readfile(a:path . a:template, "b")
if len(l:content) != 1
return a:template
endif
if filereadable(a:path . l:content[0])
return <SID>TFindLink(a:path, l:content[0])
else
return a:template
endif
endfunction
" Translate a template file name into a regular expression to test for matching
" against a given filename. As of writing this behavior is something like this:
" (with a g:templates_name_prefix set as 'template.')
"
" template.py -> ^.*py$
"
" template.test.py -> ^.*test.py$
"
function <SID>TemplateToRegex(template, prefix)
let l:template_base_name = fnamemodify(a:template,":t")
let l:template_glob = strpart(l:template_base_name, len(a:prefix))
" Translate the template's glob into a normal regular expression
let l:in_escape_mode = 0
let l:template_regex = ""
for l:c in split(l:template_glob, '\zs')
if l:in_escape_mode == 1
if l:c == '\'
let l:template_regex = l:template_regex . '\\'
else
let l:template_regex = l:template_regex . l:c
endif
let l:in_escape_mode = 0
else
if l:c == '\'
let l:in_escape_mode = 1
else
let l:tr_index = index(g:templates_tr_in, l:c)
if l:tr_index != -1
let l:template_regex = l:template_regex . g:templates_tr_out[l:tr_index]
else
let l:template_regex = l:template_regex . l:c
endif
endif
endif
endfor
if g:templates_fuzzy_start
return l:template_regex . '$'
else
return '^' . l:template_regex . '$'
endif
endfunction
" Given a template and filename, return a score on how well the template matches
" the given filename. If the template does not match the file name at all,
" return 0
function <SID>TemplateBaseNameTest(template, prefix, filename)
let l:tregex = <SID>TemplateToRegex(a:template, a:prefix)
" Ensure that we got a valid regex
if l:tregex == ""
return 0
endif
" For now only use the base of the filename.. this may change later
" *Note* we also have to be careful because a:filename may also be the passed
" in text from TLoadCmd...
let l:filename_chopped = fnamemodify(a:filename,":t")
" Check for a match
let l:regex_result = match(l:filename_chopped,l:tregex)
if l:regex_result != -1
" For a match return a score based on the regex length
return len(l:tregex)
else
" No match
return 0
endif
endfunction
" Returns the most specific / highest scored template file found in the given
" path. Template files are found by using a glob operation on the current path
" and the setting of g:templates_name_prefix. If no template is found in the
" given directory, return an empty string
function <SID>TDirectorySearch(path, template_prefix, file_name)
let l:picked_template = ""
let l:picked_template_score = 0
" All template files matching
let l:templates = split(glob(a:path . a:template_prefix . "*"), "\n")
for template in l:templates
" Make sure the template is readable
if filereadable(template)
let l:current_score =
\<SID>TemplateBaseNameTest(template, a:template_prefix, a:file_name)
call <SID>Debug("template: " . template . " got scored: " . l:current_score)
" Pick that template only if it beats the currently picked template
" (here we make the assumption that template name length ~= template
" specifity / score)
if l:current_score > l:picked_template_score
let l:picked_template = template
let l:picked_template_score = l:current_score
endif
endif
endfor
if l:picked_template != ""
call <SID>Debug("Picked template: " . l:picked_template)
else
call <SID>Debug("No template found")
endif
return l:picked_template
endfunction
" Searches for a [template] in a given [path].
"
" If [upwards] is [1] the template is searched only in the given directory;
" if it's zero it is searched all along the directory structure, going to
" parent directory whenever a template is *not* found for a given [path]. If
" it's greater than zero [upwards] is the maximum depth of directories that
" will be traversed.
"
" If no template is found an empty string is returned.
"
function <SID>TSearch(path, template_prefix, file_name, upwards)
" pick a template from the current path
let l:picked_template = <SID>TDirectorySearch(a:path, a:template_prefix, a:file_name)
if l:picked_template != ""
if !has("win32") || !has("win64")
return l:picked_template
else
echoerr( "Not yet implemented" )
" TODO
" return a:path . <SID>TFindLink(a:path, a:template)
endif
else
" File not found/not readable.
if (a:upwards == 0) || (a:upwards > 1)
" Check wether going upwards results in a different path...
let l:pathUp = <SID>DirName(a:path)
if l:pathUp != a:path
" ...and traverse it.
return <SID>TSearch(l:pathUp, a:template_prefix, a:file_name, a:upwards ? a:upwards-1 : 0)
endif
endif
endif
" Ooops, either we cannot go up in the path or [upwards] reached 1
return ""
endfunction
" Tries to find valid templates using the global g:templates_name_prefix as a glob
" matcher for template files. The search is done as follows:
" 1. The [path] passed to the function, [upwards] times up.
" 2. The g:templates_directory directory, if it exists.
" 3. Built-in templates from s:default_template_dir.
" Returns an empty string if no template is found.
"
function <SID>TFind(path, name, up)
let l:tmpl = <SID>TSearch(a:path, g:templates_name_prefix, a:name, a:up)
if l:tmpl != ''
return l:tmpl
endif
for l:directory in g:templates_directory
let l:directory = <SID>NormalizePath(expand(l:directory) . '/')
if isdirectory(l:directory)
let l:tmpl = <SID>TSearch(l:directory, g:templates_global_name_prefix, a:name, 1)
if l:tmpl != ''
return l:tmpl
endif
endif
endfor
if g:templates_no_builtin_templates
return ''
endif
return <SID>TSearch(<SID>NormalizePath(expand(s:default_template_dir) . '/'), g:templates_global_name_prefix, a:name, 1)
endfunction
" Template variable expansion. {{{1
" Makes a single [variable] expansion, using [value] as replacement.
"
function <SID>TExpand(variable, value)
silent! execute "%s/%" . a:variable . "%/" . a:value . "/g"
endfunction
" Performs variable expansion in a template once it was loaded {{{2
"
function <SID>TExpandVars()
" Date/time values
let l:day = strftime("%d")
let l:year = strftime("%Y")
let l:month = strftime("%m")
let l:time = strftime("%H:%M")
let l:date = exists("g:dateformat") ? strftime(g:dateformat) :
\ (l:year . "-" . l:month . "-" . l:day)
let l:fdate = l:date . " " . l:time
let l:filen = expand("%:t:r")
let l:filex = expand("%:e")
let l:filec = expand("%:t")
let l:fdir = expand("%:p:h:t")
let l:hostn = hostname()
let l:user = exists("g:username") ? g:username :
\ (exists("g:user") ? g:user : $USER)
let l:email = exists("g:email") ? g:email : (l:user . "@" . l:hostn)
let l:guard = toupper(substitute(l:filec, "[^a-zA-Z0-9]", "_", "g"))
let l:class = substitute(l:filen, "\\([a-zA-Z]\\+\\)", "\\u\\1\\e", "g")
let l:macroclass = toupper(l:class)
let l:camelclass = substitute(l:class, "_", "", "g")
" Finally, perform expansions
call <SID>TExpand("DAY", l:day)
call <SID>TExpand("YEAR", l:year)
call <SID>TExpand("DATE", l:date)
call <SID>TExpand("TIME", l:time)
call <SID>TExpand("USER", l:user)
call <SID>TExpand("FDATE", l:fdate)
call <SID>TExpand("MONTH", l:month)
call <SID>TExpand("FILE", l:filen)
call <SID>TExpand("FFILE", l:filec)
call <SID>TExpand("FDIR", l:fdir)
call <SID>TExpand("EXT", l:filex)
call <SID>TExpand("MAIL", l:email)
call <SID>TExpand("HOST", l:hostn)
call <SID>TExpand("GUARD", l:guard)
call <SID>TExpand("CLASS", l:class)
call <SID>TExpand("MACROCLASS", l:macroclass)
call <SID>TExpand("CAMELCLASS", l:camelclass)
call <SID>TExpand("LICENSE", exists("g:license") ? g:license : "MIT")
endfunction
" }}}2
" Puts the cursor either at the first line of the file or in the place of
" the template where the %HERE% string is found, removing %HERE% from the
" template.
"
function <SID>TPutCursor()
0 " Go to first line before searching
if search("%HERE%", "W")
let l:column = col(".")
let l:lineno = line(".")
s/%HERE%//
call cursor(l:lineno, l:column)
endif
endfunction
" File name utils
"
" Ensures that the given file name is safe to be opened and will not be shell
" expanded
function <SID>NeuterFileName(filename)
let l:neutered = fnameescape(a:filename)
call <SID>Debug("Neutered " . a:filename . " to " . l:neutered)
return l:neutered
endfunction
" Template application. {{{1
" Loads a template for the current buffer, substitutes variables and puts
" cursor at %HERE%. Used to implement the BufNewFile autocommand.
"
function <SID>TLoad()
if !line2byte( line( '$' ) + 1 ) == -1
return
endif
let l:file_name = expand("%:p")
let l:file_dir = <SID>DirName(l:file_name)
let l:depth = exists("g:template_max_depth") ? g:template_max_depth : 0
let l:tFile = <SID>TFind(l:file_dir, l:file_name, l:depth)
call <SID>TLoadTemplate(l:tFile)
endfunction
" Like the previous one, TLoad(), but intended to be called with an argument
" that either is a filename (so the file is loaded as a template) or
" a template suffix (and the template is searched as usual). Of course this
" makes variable expansion and cursor positioning.
"
function <SID>TLoadCmd(template)
if filereadable(a:template)
let l:tFile = a:template
else
let l:depth = exists("g:template_max_depth") ? g:template_max_depth : 0
let l:tName = g:templates_global_name_prefix . a:template
let l:file_name = expand("%:p")
let l:file_dir = <SID>DirName(l:file_name)
let l:tFile = <SID>TFind(l:file_dir, a:template, l:depth)
endif
call <SID>TLoadTemplate(l:tFile)
endfunction
" Load the given file as a template
function <SID>TLoadTemplate(template)
if a:template != ""
" Read template file and expand variables in it.
let l:safeFileName = <SID>NeuterFileName(a:template)
execute "keepalt 0r " . l:safeFileName
call <SID>TExpandVars()
" This leaves an extra blank line at the bottom, delete it
execute line('$') . "d"
call <SID>TPutCursor()
setlocal nomodified
endif
endfunction
" Commands {{{1
" Just calls the above function, pass either a filename or a template
" suffix, as explained before =)
"
fun ListTemplateSuffixes(A,P,L)
let l:templates = split(globpath(s:default_template_dir, g:templates_global_name_prefix . a:A . "*"), "\n")
let l:res = []
for t in templates
let l:suffix = substitute(t, ".*\\.", "", "")
call add(l:res, l:suffix)
endfor
return l:res
endfun
command -nargs=1 -complete=customlist,ListTemplateSuffixes Template call <SID>TLoadCmd("<args>")
" Syntax autocommands {{{1
"
" Enable the vim-template syntax for template files
" Usually we'd put this in the ftdetect folder, but because
" g:templates_name_prefix doesn't get defined early enough we have to add the
" template detection from the plugin itself
execute "au BufNewFile,BufRead " . g:templates_name_prefix . "* "
\. "let b:vim_template_subtype = &filetype | "
\. "set ft=vim-template"
if !g:templates_no_builtin_templates
execute "au BufNewFile,BufRead "
\. s:default_template_dir . "/" . g:templates_global_name_prefix . "* "
\. "let b:vim_template_subtype = &filetype | "
\. "set ft=vim-template"
endif
for s:directory in g:templates_directory
let s:directory = <SID>NormalizePath(expand(s:directory) . '/')
if isdirectory(s:directory)
execute "au BufNewFile,BufRead "
\. s:directory . "/" . g:templates_global_name_prefix . "* "
\. "let b:vim_template_subtype = &filetype | "
\. "set ft=vim-template"
endif
unlet s:directory
endfor
" vim: fdm=marker

View File

@ -0,0 +1,19 @@
" vim-template syntax file
" Language: vim-template
" Maintainer: Stephen Chandler Paul <thatslyude@gmail.com>
" Last Change: 2014 April 21
if exists("b:current_syntax")
finish
endif
if b:vim_template_subtype != ""
execute "runtime! syntax/" . b:vim_template_subtype . ".vim"
unlet b:current_syntax
endif
syn match vimtemplateVariable "%\%(DAY\|YEAR\|MONTH\|DATE\|TIME\|FILE\|FFILE\|EXT\|MAIL\|USER\|HOST\|GUARD\|CLASS\|MACROCLASS\|CAMELCLASS\|HERE\)%" containedin=ALL
let b:current_syntax = "vim-template"
hi def link vimtemplateVariable Constant

View File

@ -0,0 +1,11 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
#include "%FILE%.h"
%HERE%

View File

@ -0,0 +1 @@
=template=*.c

View File

@ -0,0 +1 @@
=template=*.c

View File

@ -0,0 +1,13 @@
cmake_minimum_required (VERSION 2.8)
# projectname is the same as the main-executable
project(%HERE%%FDIR%)
add_definitions('-g')
add_definitions('-Wall')
#add_definitions('-std=c++11')
add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cpp)
add_custom_target(${PROJECT_NAME}-symlink ALL ln --force -s ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/${PROJECT_NAME} DEPENDS ${PROJECT_NAME})
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_SOURCE_DIR}/${PROJECT_NAME})

View File

@ -0,0 +1 @@
=template=*.c

View File

@ -0,0 +1,12 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER%
*
* Distributed under terms of the %LICENSE% license.
*/
body {
%HERE%background: white;
color: black;
}

View File

@ -0,0 +1 @@
=template=*.c

View File

@ -0,0 +1,8 @@
!
! %FFILE%
! Copyright (C) %YEAR% %USER% <%MAIL%>
!
! Distributed under terms of the %LICENSE% license.
!
%HERE%

View File

@ -0,0 +1,8 @@
!
! %FFILE%
! Copyright (C) %YEAR% %USER% <%MAIL%>
!
! Distributed under terms of the %LICENSE% license.
!
%HERE%

View File

@ -0,0 +1,13 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
#ifndef %GUARD%
#define %GUARD%
%HERE%
#endif /* !%GUARD% */

View File

@ -0,0 +1,12 @@
#! /usr/bin/env runhugs +l
--
-- %FFILE%
-- Copyright (C) %YEAR% %USER% <%MAIL%>
--
-- Distributed under terms of the %LICENSE% license.
--
module %FILE% where
%HERE%

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>%FILE%</title>
</head>
<body>
%HERE%
</body>
</html>

View File

@ -0,0 +1,16 @@
/* TEAM */
Your title: %USER%
Site: %MAIL%, link to a contact form, etc.
Twitter: your Twitter username.
Location: City, Country.
%HERE%
/* THANKS */
Name: name or url
/* SITE */
Last update: YYYY/MM/DD
Standards: HTML5, CSS3,..
Components: Modernizr, jQuery, etc.
Software: Software used for the development

View File

@ -0,0 +1,14 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
public class %FILE%
{
public %FILE%() {
%HERE%
}
}

View File

@ -0,0 +1,8 @@
#=
%FILE%
Copyright © %YEAR% %USER% <%MAIL%>
Distributed under terms of the %LICENSE% license.
=#
%HERE%

View File

@ -0,0 +1,7 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
%HERE%

View File

@ -0,0 +1,4 @@
%FILE% by %USER%
%FDATE%
%HERE%

View File

@ -0,0 +1,9 @@
#! /usr/bin/env lua
--
-- %FFILE%
-- Copyright (C) %YEAR% %USER% <%MAIL%>
--
-- Distributed under terms of the %LICENSE% license.
--
%HERE%

View File

@ -0,0 +1 @@
=template=*.c

View File

@ -0,0 +1 @@
=template=*Makefile

View File

@ -0,0 +1,9 @@
(*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*)
let %HERE%

View File

@ -0,0 +1 @@
=template=*.m

View File

@ -0,0 +1,13 @@
<?php
/**
* Short description for %FFILE%
*
* @package %FILE%
* @author %USER% <%MAIL%>
* @version 0.1
* @copyright (C) %YEAR% %USER% <%MAIL%>
* @license %LICENSE%
*/
%HERE%
?>

View File

@ -0,0 +1,16 @@
#! /usr/bin/env perl
#
# Short description for %FFILE%
#
# Author %USER% <%MAIL%>
# Version 0.1
# Copyright (C) %YEAR% %USER% <%MAIL%>
# Modified On %FDATE%
# Created %FDATE%
#
use strict;
use warnings;
%HERE%

View File

@ -0,0 +1,38 @@
package %FILE%;
#
# Short description for %FFILE%
#
# Author %USER% <%MAIL%>
# Version 0.1
# Copyright (C) %YEAR% %USER% <%MAIL%>
# Modified On %FDATE%
# Created %FDATE%
#
use strict;
use warnings;
our @ISA = qw(Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
our $VERSION = '1.00';
require Exporter;
use AutoLoader qw(AUTOLOAD);
sub new
{
my $class = shift;
my $arg = shift;
my $self = {};
%HERE%
bless($self, $class);
return $self;
}
1;
# __END__
# # Below is stub documentation for your module. You'd better edit it!

View File

@ -0,0 +1,26 @@
PRO %FILE%
;+
; Name:
; %FILE%
; Purpose:
;
; Calling sequence:
; %FILE%
; Input:
;
; Output:
;
; Keywords:
;
; History:
;
; Author:
; Copyright © %YEAR% %USER% <%MAIL%>
; Distributed under terms of the %LICENSE% license.
;-
COMPILE_OPT IDL2 ;Set compile options
%HERE%
END

View File

@ -0,0 +1,14 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © %YEAR% %USER% <%MAIL%>
#
# Distributed under terms of the %LICENSE% license.
#
# %CLASS%
#
"""
%HERE%
"""

View File

@ -0,0 +1,10 @@
#!/usr/bin/env ruby
#
# %FFILE%
# Copyright (C) %YEAR% %USER% <%MAIL%>
#
# Distributed under terms of the %LICENSE% license.
#
%HERE%

View File

@ -0,0 +1,6 @@
#
# The Web Robots Pages (http://www.robotstxt.org/)
#
User-agent: *
Disallow:

View File

@ -0,0 +1,10 @@
#! /bin/sh
#
# %FFILE%
# Copyright (C) %YEAR% %USER% <%MAIL%>
#
# Distributed under terms of the %LICENSE% license.
#
%HERE%

Some files were not shown because too many files have changed in this diff Show More