Using an external text editor rather than editing in your browser (MediaWiki)

From WhyNotWiki

Jump to: navigation, search

MediaWiki tools  edit   (Category  edit)

Has associated category


MediaWiki  edit   (Category  edit)


Editing textareas with an external text editor  edit   (Category  edit)


  • Read Editing textareas with an external text editor for information on how to set up your browser / text editor so that you can edit any textarea using your favorite editor (including but not limited to those on MediaWiki-powered sites).

[edit] MediaWiki syntax/editing support for vim

http://en.wikipedia.org/wiki/Wikipedia:Text_editor_support

It is often convenient to edit Wikipedia articles using a full-fledged text editor, instead of the standard text area of a web browser. Text editors provide facilities that are very useful for writing articles (especially long articles), such as spell checking, search and replace, macros, and syntax highlighting. They also provide a quick and easy way of saving a local backup copy of an article, possibly for future offline editing.

[edit] Vim

To make Vim support the MediaWiki markup used on Wikipedia, save Wikipedia.vim to your "syntax" directory. By default, this directory is "~/.vim/syntax" on a Unix system, and "C:\Program Files\Vim\vimfiles\syntax" on a Windows system.

To autodetect files ending in ".wiki", add the following lines to ".vim/filetype.vim" or "vimfiles\filetype.vim" (or create the file if it doesn't exist):

augroup filetypedetect
au BufNewFile,BufRead *.wiki setf Wikipedia
augroup END

Alternatively, add the following line to the vimrc file (typically ~/.vimrc on Unix and C:\Program Files\Vim\_vimrc on Windows) (this doesn't work in Vim 7, use the above example):

au BufRead,BufNewFile *.wiki setfiletype Wikipedia

Alternatively, the command ":setf Wikipedia" will temporarily set the syntax for the current file.

The above mentioned Firefox extension Mozex creates a temporary file ending in ".txt" rather than ".wiki" so the above autodetection will not work in combination with that plugin. One solution is to have Mozex invoke vim with these arguments:

-c "setf Wikipedia"

Wikipedia articles often only have line-breaks at the end of each paragraph, a situation Vim doesn't handle gracefully by default. Save the following lines to "~/.vim/ftplugin/Wikipedia.vim" or "vimfiles\ftplugin\Wikipedia.vim" to make it easier (you may need to put "filetype plugin on" in your vimrc).

setlocal textwidth=0
setlocal linebreak
setlocal matchpairs+=<:>
nnoremap <buffer> k gk
nnoremap <buffer> j gj
nnoremap <buffer> <Up> gk
nnoremap <buffer> <Down> gj
nnoremap <buffer> 0 g0
nnoremap <buffer> ^ g^
nnoremap <buffer> $ g$
inoremap <buffer> <Up> <C-O>gk
inoremap <buffer> <Down> <C-O>gj
vnoremap <buffer> k gk
vnoremap <buffer> j gj
vnoremap <buffer> <Up> gk
vnoremap <buffer> <Down> gj
vnoremap <buffer> 0 g0
vnoremap <buffer> ^ g^
vnoremap <buffer> $ g$

Please feel free to edit Wikipedia.vim and upload an improved copy, or to check on the vim-devel list if anyone has requested the upload of Wikipedia.vim, and if not, to request it. (As of 2006-09-06, it is not in Vim's "syntax/" directory.)

http://meta.wikimedia.org/wiki/Help:External_editors

  • Set up MIME type/helper app
  • Bookmarklet for text editing

The MediaWiki software allows you to edit any resource using any external tool. This is accomplished using a very simple system:

  1. When a resource is requested for being edited externally, MediaWiki sends out a control file that contains information about the resource; most importantly, its network location (URL) and the interface that is to be used for changing it.
  2. The user has to configure his or her browser so that the MIME type application/x-external-editor is associated with a special helper application. With Firefox 2 you can edit MIME type via "Tools/Options/Content/Manage". (Firefox 1.x was notorious for its problematic MIME handling. A helper extension like Mime Type Editor 0.2 is recommended for older FF versions.)
  3. That helper application processes the control file, retrieves the resource, launches the favored application to edit it, and, if desired, saves the resource back to the server.
Personal tools