You are not logged in.

#1 2012-06-16 13:52:49

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,176
Website

Post to the forums from vim

Dear Archers,

TLDR: This is a how-to targeted at chrom{e,ium} users for preparing forum posts in vim (with bbcode syntax highlighting no less).

Longer:
I thought the vim users here, especially those who use vimium, would like to know a little trick I've found for posting to the forums. I'm using it while writing this post big_smile.
   
Steps:

  1. GetTextAid.

  2. Get edit-server. You might want to edit the script - I'm still trying to get it to work with vim in a console rather than gvim.

  3. Get the bbcode syntax file. You might also want to edit this, eg,

    --- /home/whoami/Downloads/bbcode.vim	2012-06-16 23:11:48.328849555 +1000
    +++ /home/whoami/.vim/syntax/bbcode.vim	2012-06-16 16:28:59.104913597 +1000
    @@ -35,12 +35,16 @@
     syn region bbcodeUnderlineItalicBold contained start="\[b\]" end="\[/b\]"me=e-4 contains=bbcodeTag
     
     syn region bbcodeUrl start="\[url\s*[=\]]" end="\[/url\]"me=e-6 contains=@NoSpell,bbcodeTag
    +syn region bbcodeCode start="\[code\]" end="\[/code\]"me=e-6 contains=@NoSpell,bbcodeTag
    +syn region bbquoteQuote start="\[quote\]" end="\[/quote\]"me=e-6 contains=@NoSpell,bbquoteTag
     
     hi link bbcodeTag Identifier
     hi link bbcodeItem Statement
     hi link bbcodeArgument Type
     hi link bbcodeValue Constant
     hi link bbcodeUrl Underlined
    +hi link bbcodeCode Statement
    +hi link bbcodeQuote Special
     
     hi link bbcodeBoldUnderlineItalic bbcodeBoldItalicUnderline
     hi link bbcodeItalicBold bbcodeBoldItalic
  4. In your vimrc, detect when you should have the bbcode syntax on:

    au BufRead,BufNewFile edit-server-* set filetype=bbcode
  5. Run edit server; maybe call it in your .xinitrc or .profile, or start it in a screen session.

  6. Activate TextAid in some appropriate text box. The first time you run it, you'll configure it with username/password, url:port, and a key-binding; after that it won't bother you again.

If all goes well, whenever you've selected a forum text box, you can now press your keybinding to fire up a vim session. If the box already contains text (such as from pressing Quote), that will appear in your vim session too. When you exit, the text from vim should appear in the text box.

Screenshot:
YAW2t.png

(As you can see, the syntax highlighting could use more work ...)


Linux is NOT Windows | The Rootless Root
Toshiba Satellite i5-3230M 2.6GHz CPUs, 4Gb RAM, ArchLinux, wmii, nVidia GeForce GT 740M.

Offline

Board footer

Powered by FluxBB