Vim Tips Wiki
Register
Edit Page
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
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 <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
+
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
 
<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 <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.
+
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.
 
<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 <code>/Applications/MacVim.app/Contents/Resources/vim/runtime/synmenu.vim</code>
+
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>
   
 
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 <code>.vim/syntax/confluencewiki.vim</code> 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 <tt>.vim/syntax/confluencewiki.vim</tt> 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 <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.
+
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.
   
''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. :-)
+
''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. :-)
   
 
==Wiki syntax editor deprecated in version 4.0+==
 
==Wiki syntax editor deprecated in version 4.0+==
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)

Template used on this page: