Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Help:Text editor support
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====$HOME/.vim/ftdetect/mediawiki.vim==== =====Basic filetype detection===== To autodetect files ending in "{{tt|.wiki}}", add the following lines to "<kbd>.vim/ftdetect/mediawiki.vim</kbd>" or "<kbd>vimfiles\ftdetect\mediawiki.vim</kbd>" (or create the file if it doesn't exist): A raw mediawiki.vim file for easy downloading exists on GitHub:<br> https://raw.githubusercontent.com/chikamichi/mediawiki.vim/master/ftdetect/mediawiki.vim {{File title| $HOME/.vim/ftdetect/mediawiki.vim}} <syntaxhighlight lang="vim"> if has("autocmd") au BufRead,BufNewFile *.mw set filetype=mediawiki au BufRead,BufNewFile *.wiki set filetype=mediawiki au BufRead,BufNewFile *.mediawiki set filetype=mediawiki au BufRead,BufNewFile *.wikipedia.org* set filetype=mediawiki au BufRead,BufNewFile *.wikibooks.org* set filetype=mediawiki au BufRead,BufNewFile *.wikimedia.org* set filetype=mediawiki endif </syntaxhighlight> Alternatively, the command "<kbd>:setf mediawiki</kbd>" will temporarily set the syntax for the current file. =====Mozex Firefox extension fix===== If you use the <b>Mozex Firefox extension</b>,<ref name="Mozex">{{cite web |last=Marek |first=Vladimir |title=Mozex |publisher=MozDev |date=2009-12-27 |url= http://mozex.mozdev.org/ |url-status=dead |archiveurl= https://web.archive.org/web/20200708154331/http://mozex.mozdev.org/ |archivedate=2020-07-08}}</ref> <b>Mozex</b> creates a temporary file ending in "{{tt|.txt}}" rather than "{{tt|.wiki}}" so the above autodetection will not work in combination with that add-on. One solution is to have <b>Mozex</b> invoke vim with these arguments: -c "setf mediawiki" A complete editor command can look some thing like that gnome-terminal -e "vim -c 'setf mediawiki' $1" According to the surviving download mirrors of the now-defunct MozDev site, Mozex was last updated on 11 March 2010 (v. 1.9.12),<ref>{{cite web |title=Index of /pub/mirrors/mozdev.org/mozex/ |publisher=ibiblio.org |date=2010-03-11 |url= https://mirrors.ibiblio.org/pub/mirrors/mozdev.org/mozex/ |accessdate=2025-05-03}}</ref> and per this version's install.rdf file, it supports Firefox 3.7.*. Mozex also supports the Mozilla Application Suite,<ref>{{cite web |last=Marek |first=Vladimir |title=Installation |work=Mozex |publisher=MozDev |url=http://mozex.mozdev.org/installation.html |url-status=dead |archiveurl= https://web.archive.org/web/20200602033602/http://mozex.mozdev.org/installation.html |archivedate=2020-06-02}}</ref> its continuation SeaMonkey up to version 1.1.19, [[Classilla]] (for Mac), RetroZilla,<ref>{{cite web |author=rn10950 |title=RetroZilla |publisher=GitHub |date=2024-05-26 |url=https://github.com/rn10950/RetroZilla |accessdate=2024-05-23}}</ref> and further derivatives. =====Adapt to MediaWiki lines without line breaks===== Wikipedia articles often only have line-breaks at the end of each paragraph, a situation Vim by default doesn't handle as other text editors. Save the following lines to "<kbd>~/.vim/ftplugin/mediawiki.vim</kbd>" or "<kbd>vimfiles\ftplugin\mediawiki.vim</kbd>" to make it as you may be used to from Notepad: {{File title| $HOME/.vim/ftplugin/mediawiki.vim}} <syntaxhighlight lang="vim"> " Many MediaWiki wikis prefer line breaks only at the end of paragraphs " (like in a text processor), which results in long, wrapping lines. setlocal wrap linebreak setlocal textwidth=0 " No auto-wrap at all. setlocal formatoptions-=t formatoptions-=c formatoptions-=a formatoptions+=l " Make navigation more amenable to the long wrapping lines. noremap <buffer> k gk noremap <buffer> j gj noremap <buffer> <Up> gk noremap <buffer> <Down> gj noremap <buffer> 0 g0 noremap <buffer> ^ g^ noremap <buffer> $ g$ noremap <buffer> D dg$ noremap <buffer> C cg$ noremap <buffer> A g$a inoremap <buffer> <Up> <C-O>gk inoremap <buffer> <Down> <C-O>gj </syntaxhighlight> =====Additional gimmicks===== Additional to that you may want to save the following lines to "<kbd>~/.vim/ftplugin/mediawiki.vim</kbd>" or "<kbd>vimfiles\ftplugin\mediawiki.vim</kbd>" for some more gimmicks (you may need to put "<kbd>filetype plugin on</kbd>" in your <code>vimrc</code>): <div style="height:auto; overflow:auto;"> {{File title| $HOME/.vim/ftplugin/mediawiki.vim}} <syntaxhighlight lang="vim"> " utf-8 should be set if not already done globally setlocal fileencoding=utf-8 setlocal matchpairs+=<:> " Treat lists, indented text and tables as comment lines and continue with the " same formatting in the next line (i.e. insert the comment leader) when hitting " <CR> or using "o". setlocal comments=n:#,n:*,n:\:,s:{\|,m:\|,ex:\|} setlocal formatoptions+=roq " match HTML tags (taken directly from $VIM/ftplugin/html.vim) if exists("loaded_matchit") let b:match_ignorecase=0 let b:match_skip = 's:Comment' let b:match_words = '<:>,' . \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' . \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' . \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' endif " Other useful mappings " Insert a matching = automatically while starting a new header. inoremap <buffer> <silent> = <C-R>=(getline('.')==''\|\|getline('.')=~'^=\+$')?"==\<Lt>Left>":"="<CR> " Enable folding based on ==sections== setlocal foldexpr=getline(v:lnum)=~'^\\(=\\+\\)[^=]\\+\\1\\(\\s*<!--.*-->\\)\\=\\s*$'?\">\".(len(matchstr(getline(v:lnum),'^=\\+'))-1):\"=\" setlocal fdm=expr </syntaxhighlight></div> ===== GVim Syntax menu ===== Add in Syntax menu the option Wiki {{File title| $HOME/.vim/synmenu.vim}} <syntaxhighlight lang="vim"> an 50.150.450 &Syntax.WXYZ.Wiki :cal SetSyn("mediawiki")<CR> </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)