Vim and Open-With plugin enhancements

20 views
Skip to first unread message

TL

unread,
Apr 11, 2008, 1:43:16 PM4/11/08
to leo-editor
The lastest update to the Open-With/Vim enhancements has been uploaded
to the Vim branch on the Launchpad website. User configuration of the
features has been added.

For existing users of the Open-With and Vim plugins, the following
summary should provide a good overview of the new features and how to
use them.

Note: The summary uses embedded line-feeds and leading spaces to help
make the content more readable. A "Vim_Enhancements.otl' version of
the file, created by Vim's TVO ouliner plugin, can be obtained from
the Files section of this forum. The file is very readable in any
text editor (use fixed-width fonts if possible)

Leo enhancements:
The following enhancements are part of the update Open-With/Vim
plugins.

1 Cursor position
To facilitate the transition from editing a node's text
in Leo to editing it within Vim, the Vim plugin can now
be configured to initially positions the Vim cursor on the
same line of text as Leo's cursor.

2 Tab cards
To support those Vim users who manage multiple files within
a single Vim window by utilizing Vim's built-in tab card
functionality, the Vim plugin can now be configured to send
the nodes to Vim such that Vim displays them in a tab cards.
(Note: Help on Vim's tab cards feature is available within
the Vim application by issuing the command :help tabpage)

3 Tab card labels
To better reflect the associated node's headline text in the
Vim tab card label, the Open-With plugin can now be
configured to use a temporary filename based only on the
node's headline extnsion.
be of use for other editors supported by the Open-With plugin)

4 Node association
To determine which Leo node is associated with the currently
displayed file in Vim, the Open-With plugin can now be
configured to store the temporary file using a directory
path that mirrors the node's ancestors in the Leo outline.
Vim can be configured to display the directory path as a
tooltip (see Vim enhancements below).

5 Vim styles
To more easily use Vim's file type specific configurations
(based on the file's extension), the Open-With plugin will
now use the file extension from the node's derived file, if
it exists, to build the temporary file sent to the external
editor.

The Vim plugin changes reside in the 'open_in_vim' function in
vim.py file (items #1 and #2).

The Open-With plugin changes reside in the 'openWithTempFilePath'
function in the mod_tempfname.py file (items #3, #4, and #5).

Note: The Open-With plugin changes should be useful with other
external editors using the Open-With plugin.

Leo configuration:
The following variables have been added to Leo to provide
selective use of Leo's Open-With/Vim enhancements. The Default
configuraton settings have been set to "False" in leoSettings.leo
to maintain the previous functionality. The enhancements can be
enabled by setting the appropriate variables to "True" in your
myLeoSettings.leo file. For example:
@bool vim_tab_feature_used = True

vim_plugin_positions_cursor (Leo enhanncement #1)
True/False, enable/disable whether the cursor is initially
positioned in the same row as the Leo cursor.
Default: @bool vim_plugin_position_cursor = False

vim_plugin_uses_tab_feature (Leo enhancement #2)
True/False, enable/disable the sending of Vim file to a Vim
tab card instead of the current visable Vim buffer.
Default: @bool vim_plugin_uses_tab_feature = False

open_with_clean_filenames (Leo enhancement #3 & #4)
True/False, use new or old method for storing temporary files.
Default: @bool open_with_clean_filenames = False

open_with_uses_derived_file_Extensions (Leo enhancement #5)
True/False, have the Open-With plugin use the extension of
the node's derived file if an ancestor @file node exists to
form the temporary file name. Otherwise, the @language
extension is used or '.txt'.
Default: @bool open_with_uses_derived_file_extensions = False

Vim configuration:
The following Vim configurations can enhance the use of Vim as an
external editor for the Open-With/Vim plugins. The configuration
commands presented below can be entered from the Vim command or
automatically applied by adding the commands to Vim's .vimrc
initialization file or its equivelent.
For help on Vim's initialization files, issue the following Vim
commands: ":help vimrc-intro" and ":help .vimrc"

Hide sentinel lines
Vim's line folding functionality can be used to hide the
sentinel lines when editing a derived file in Vim. The
following Vim commands will fold consecutive sentinel lines
in a file into a single line of dashes.
set foldmethod=expr "Fold lines that match a pattern
set foldexpr=getline(v:lnum)[1]==\"@\" "Define pattern
set foldminlines=1 "Fold any number of consecutive lines
set foldtext=v:folddashes "Folded lines shown as dashes

For help on the folding feature, enter ":help folding" in Vim

Tab cards
Using Vim's tab card feature can make working with multiple
files in Vim more comfortable as each file will be maintained
in a separate tab card as part of a tab card stack. The
following command will configure Vim to always show the tab
card stack even if only one file is being edited:
set showtabline=2 "Always display the tab card stack

For help on Vim's tab cards, enter ":help tabpage" in Vim
Note: If the tab card stack is not configured to always be
displayed but Leo's Vim plugin has been configured to
export files into Vim tab cards then the tab card stack
will be displayed after Vim receives two files.
(see 'vim_plugin_uses_tab_feature' above)

Tab card labels (supports Leo enhancement #2, #3, and #4)
The label associated with each tab card can be configured to
only contain the associated file's file name using the
following Vim command:
set guitablabel=%M "Show file's base file name in label

If Leo has been configured to generate temporary files with
clean file names ('open_with_clean_filenames' set to "True")
then the tab card label will contain the text of the associated
node's headline.

Note: The file's extension can be included using:
set guitablabel=%M%t "Filename (%M=basename, %t=extension)
For help on tab labels, enter ":help guitablabel" in Vim

Tab card tooltips (supports Leo enhancement #4)
User's can view the association of a tab card back to the Leo
node from which it was created by displaying the associated
node's Leo ouline hierarchy in the tab card's tooltip. This
is achieved by mirroring the node's Leo outline in the
temporary file sent to vim (achieved by setting the
'open_with_clean_filenames' configuration variable in Leo to
"True") and configuring Vim to display the file's directory
path in the tab card tooltip using the following command:
set guitabtooltip=%F "Display tooltip (%F=file's path)

For help on tab tooltips, enter ":help guitabtooltip" in Vim.

Edward K. Ream

unread,
Apr 11, 2008, 1:59:40 PM4/11/08
to leo-e...@googlegroups.com
On Fri, Apr 11, 2008 at 12:43 PM, TL <t...@tltools.net> wrote:

The lastest update to the Open-With/Vim enhancements has been uploaded
to the Vim branch on the Launchpad website.  User configuration of the
features has been added.

Excellent docs!  Many thanks for this work.

Edward

TL

unread,
Apr 13, 2008, 3:15:35 PM4/13/08
to leo-editor
Correction:
The changes attributed to the "Open With" plugin were actually made in
the mod_tempfname.py plugin. This plugin is not enabled by default.
The following line must be added to the @enabled-plugins node in
leoSettings.leo or, better, in myLeoSettings.leo:

mod_tempfname.py

Sorry for the confusion.

TL

bobjack

unread,
Apr 14, 2008, 5:05:03 AM4/14/08
to leo-editor
Hi Tl

Thanks for the vim enhancements, I like them a lot. Thanks also for
the tips on setting up Vim, the folding trick for leo sentinals was
especially cool.

One small bug I noticed though. You can not now edit the first node of
an @thin file, wheras before you could.

Bob

TL

unread,
Apr 14, 2008, 10:48:43 PM4/14/08
to leo-editor
Thanks Bob for the positive feedback.

Concerning the handling of @file type nodes, I am also using the
FileActions plugin which also reacts to double-click events on nodes.
After Edward replied to my question about Leo's handling of multiple
event handlers, I found a solution that will invoke Vim only if the
FileActions plugin does not have a match for the node. I've pushed
the changes, including changes to the FileActions plugin to the Vim
branch on Launchpad.

Regards,
TL
Reply all
Reply to author
Forward
0 new messages