Wikia

Vim Tips Wiki

Changes: Script:1994

Edit

Back to page

(Additional information on slowness on certain constructs.)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
I prefer to edit my confluence documents in Vim instead of the built-in confluence editor.
 
I prefer to edit my confluence documents in Vim instead of the built-in confluence editor.
   
Sometimes instead of posting half completed documents back to confluence I save them on my local machine. To have Vim automatically recognize them I add an entry to <tt>~/.vim/filetype.vim</tt> to automatically handle them. Instead of creating a custom file extension for Vim to recognize, I have it parse the file for the word confluence in the document. Instead of having to have all my confluence pages show the word confluence in the rendered version, the hack is to add hidden text to the top of your confluence files that won't show up when you are in viewing mode on confluence but does when you edit. Just add
+
Sometimes instead of posting half completed documents back to confluence I save them on my local machine. To have Vim automatically recognize them I add an entry to <code>~/.vim/filetype.vim</code> to automatically handle them. Instead of creating a custom file extension for Vim to recognize, I have it parse the file for the word confluence in the document. Instead of having to have all my confluence pages show the word confluence in the rendered version, the hack is to add hidden text to the top of your confluence files that won't show up when you are in viewing mode on confluence but does when you edit. Just add
 
<pre>
 
<pre>
 
{hidden-data}confluence{hidden-data}
 
{hidden-data}confluence{hidden-data}
Line 10: Line 10:
 
to the top of the doc.
 
to the top of the doc.
   
The following <tt>~/.vim/filetype.vim</tt> entry reads in the first line and regex searches for the word confluence and if found sets syntax type confluencewiki.
+
The following <code>~/.vim/filetype.vim</code> entry reads in the first line and regex searches for the word confluence and if found sets syntax type confluencewiki.
 
<pre>
 
<pre>
 
au BufNewFile,BufRead * if getline(1) =~ 'confluence'| setfiletype confluencewiki | endif
 
au BufNewFile,BufRead * if getline(1) =~ 'confluence'| setfiletype confluencewiki | endif
Line 22: Line 22:
   
 
==Adding Confluence wiki syntax to the Vim gui menu dropdowns==
 
==Adding Confluence wiki syntax to the Vim gui menu dropdowns==
Open the appropriate Vim runtime syntax menu file for editing. For me it was <tt>/Applications/MacVim.app/Contents/Resources/vim/runtime/synmenu.vim</tt>
+
Open the appropriate Vim runtime syntax menu file for editing. For me it was <code>/Applications/MacVim.app/Contents/Resources/vim/runtime/synmenu.vim</code>
   
 
Find the in between space where your entry should go (they are incremented by 10s so you have 9 in between spaces).
 
Find the in between space where your entry should go (they are incremented by 10s so you have 9 in between spaces).
Line 39: Line 39:
 
</pre>
 
</pre>
   
Save the file. Restart Vim in GUI mode – this applies to MacVim as well. It should now show up in the Syntax filetypes listing and presuming you added the <tt>.vim/syntax/confluencewiki.vim</tt> file correctly, you can now select that syntax type for the current document.
+
Save the file. Restart Vim in GUI mode – this applies to MacVim as well. It should now show up in the Syntax filetypes listing and presuming you added the <code>.vim/syntax/confluencewiki.vim</code> file correctly, you can now select that syntax type for the current document.
   
 
Since these files are owned by the installation package, you'll have to redo this if you reinstall or add a new version as it will overwrite all this.
 
Since these files are owned by the installation package, you'll have to redo this if you reinstall or add a new version as it will overwrite all this.
   
 
==Bugs==
 
==Bugs==
Having incomplete <tt>{note:title}</tt> some notes here <tt>{info}</tt> blocks can cause your Vim buffer to seem hung. I haven't investigated why, but opening the doc in another text editor and properly closing the block seems to enable Vim to go back to functioning properly. I have to kill the process for the hung buffer though. I can also kill the process, open Vim again, turn off syntax highlighting, edit the document with the malformed note block to fix it, and then turn syntax highlighting back on.
+
Having incomplete <code>{note:title}</code> some notes here <code>{info}</code> blocks can cause your Vim buffer to seem hung. I haven't investigated why, but opening the doc in another text editor and properly closing the block seems to enable Vim to go back to functioning properly. I have to kill the process for the hung buffer though. I can also kill the process, open Vim again, turn off syntax highlighting, edit the document with the malformed note block to fix it, and then turn syntax highlighting back on.
   
''Marnix Klooster says:'' At least in version 0.1.0, I have the same problem using <tt>{mockup:Some nice dialog mock-up|1}</tt>, which is generated by the Confluence plugin for Balsamiq (see http://support.balsamiq.com/customer/portal/articles/113837 for details). Vim doesn't hang for me, but it becomes very slow every time this piece of text scrolls into view. As a workaround, I've hacked the <tt>syntax match confluenceTag</tt> line to use the simpler <tt>"{\%(\w\|-\)\+\([:|]\([^:|}]*\)\)*}"</tt> regex. Everything seems to still work. However, this is my first vim syntax file experience. :-)
+
''Marnix Klooster says:'' At least in version 0.1.0, I have the same problem using <code>{mockup:Some nice dialog mock-up|1}</code>, which is generated by the Confluence plugin for Balsamiq (see http://support.balsamiq.com/customer/portal/articles/113837 for details). Vim doesn't hang for me, but it becomes very slow every time this piece of text scrolls into view. As a workaround, I've hacked the <code>syntax match confluenceTag</code> line to use the simpler <code>"{\%(\w\|-\)\+\([:|]\([^:|}]*\)\)*}"</code> regex. Everything seems to still work. However, this is my first vim syntax file experience. :-)
   
 
==Wiki syntax editor deprecated in version 4.0+==
 
==Wiki syntax editor deprecated in version 4.0+==

Latest revision as of 09:43, July 14, 2012

Use this page to discuss script 1994 confluencewiki: syntax highlighting for Atlassian Confluence wiki

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on vim.org).
  • This page may be out of date: check the script's vim.org page above, and its release notes.

Making Vim automatically recognize Confluence docsEdit

I prefer to edit my confluence documents in Vim instead of the built-in confluence editor.

Sometimes instead of posting half completed documents back to confluence I save them on my local machine. To have Vim automatically recognize them I add an entry to ~/.vim/filetype.vim to automatically handle them. Instead of creating a custom file extension for Vim to recognize, I have it parse the file for the word confluence in the document. Instead of having to have all my confluence pages show the word confluence in the rendered version, the hack is to add hidden text to the top of your confluence files that won't show up when you are in viewing mode on confluence but does when you edit. Just add

{hidden-data}confluence{hidden-data}

to the top of the doc.

The following ~/.vim/filetype.vim entry reads in the first line and regex searches for the word confluence and if found sets syntax type confluencewiki.

au BufNewFile,BufRead * if getline(1) =~ 'confluence'| setfiletype confluencewiki | endif

You can always set the filetype while you are editing with the command

:set filetype=confluencewiki

to syntax highlight the current buffer.

Adding Confluence wiki syntax to the Vim gui menu dropdownsEdit

Open the appropriate Vim runtime syntax menu file for editing. For me it was /Applications/MacVim.app/Contents/Resources/vim/runtime/synmenu.vim

Find the in between space where your entry should go (they are incremented by 10s so you have 9 in between spaces).

This applies generally to any syntax that isn't bundled with Vim, but if you wanted to add support for the confluencewiki syntax you downloaded from here, the alphabetic-orderingly appropriate space is:

an 50.20.370 &Syntax.C.Config.Generic\ Config\ file :cal SetSyn("conf")<CR>
an 50.20.380 &Syntax.C.CRM114 :cal SetSyn("crm")<CR>

and you would add a line with numbering in between so that it now looks like:

an 50.20.370 &Syntax.C.Config.Generic\ Config\ file :cal SetSyn("conf")<CR>
an 50.20.375 &Syntax.C.Confluence :cal SetSyn("confluencewiki")<CR>
an 50.20.380 &Syntax.C.CRM114 :cal SetSyn("crm")<CR>

Save the file. Restart Vim in GUI mode – this applies to MacVim as well. It should now show up in the Syntax filetypes listing and presuming you added the .vim/syntax/confluencewiki.vim file correctly, you can now select that syntax type for the current document.

Since these files are owned by the installation package, you'll have to redo this if you reinstall or add a new version as it will overwrite all this.

BugsEdit

Having incomplete {note:title} some notes here {info} blocks can cause your Vim buffer to seem hung. I haven't investigated why, but opening the doc in another text editor and properly closing the block seems to enable Vim to go back to functioning properly. I have to kill the process for the hung buffer though. I can also kill the process, open Vim again, turn off syntax highlighting, edit the document with the malformed note block to fix it, and then turn syntax highlighting back on.

Marnix Klooster says: At least in version 0.1.0, I have the same problem using {mockup:Some nice dialog mock-up|1}, which is generated by the Confluence plugin for Balsamiq (see http://support.balsamiq.com/customer/portal/articles/113837 for details). Vim doesn't hang for me, but it becomes very slow every time this piece of text scrolls into view. As a workaround, I've hacked the syntax match confluenceTag line to use the simpler "{\%(\w\|-\)\+\([:|]\([^:|}]*\)\)*}" regex. Everything seems to still work. However, this is my first vim syntax file experience. :-)

Wiki syntax editor deprecated in version 4.0+Edit

According to Atlassian, the wiki syntax editing is not a gui feature, but they do allow you to paste in wiki syntax and have it autoconvert it to Rich Text so this plugin should still be useful for local editing.

CommentsEdit

I've been using this for about a year now and love it. --March 8, 2012

Around Wikia's network

Random Wiki