Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork92
JuliaEditorSupport/julia-vim
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Julia support for Vim.
The full documentation is available from Vim: after installation, you just need to type:help julia-vim
.
The remainder of this README will only give an overview of some of the features:
This plug-in adds some functionality to substitute LaTeX code sequences (e.g.\alpha
) with correspondingUnicode symbols (e.g.α
). By default, these substitutions must be triggered explicitly by pressing theTab key, as in the Julia command line (the REPL); however, an automatic, as-you-type mode can alsobe activated, and a method based on keymap is also available.
This feature also works in command mode, e.g. when searching the files with the/
or?
commands, but theas-you-type mode is not available (the keymap-based version works though, and it also works with some Vimcommands likef
andt
).
By default, this feature is only active when editing Julia files. However, it can be also enabled withother file types, and even turned on/off on the fly regardless of the file type.
These features only work as described with Vim version 7.4 or higher. Tab completion can still be madeavailable on lower Vim versions, see below for more details. Also note that this functionality is incompatiblewith plugins that force lazy-loading, such asfiletype.nvim (most of the code is loaded lazily anyway).
The following sections provide details on these features. The complete documentation is provided by calling:help julia-vim
from within Vim. A complete reference table of the available substitution can beaccessed by calling:help L2U-ref
from within Vim.
This plug-in adds a mapping to theTab key which makes it behave like the Julia REPL, i.e. whenthe cursor is at the end of a recognized LaTeX symbol (e.g.\alpha
) in insert mode, pressingtheTab key will substitute it with the corresponding Unicode symbol (e.g.α
). If a partial matchis found (e.g.\al
), a list of possible completions is suggested (e.g.\aleph
,\allequal
,\alpha
), and it will be refined while you enter more characters; when only one match is left, pressingTab will complete it and pressing it again will perform the substitution to Unicode.
If no suitable substitution is found, the action will fall back to whatever mapping was previouslydefined: by default, inserting a literal<Tab>
character, or invoking some other action if anotherplug-in is installed, e.g.supertab orYouCompleteMe.
Note that theYouCompleteMe,neocomplcache,neocomplete anddeoplete plug-ins do not work wellwith the suggestion of possible completions for partial matches, and therefore this feature is disabledif those plug-ins are detected.
A literal tab can always be forced by usingCTRL-V and thenTab.
On the Vim command line, e.g. when searching the file with the/
or?
commands, the feature isalso activated byTab, but falls-back to the Vim built-in behavior if no suitable substitutionis found: if you had defined a mapping forTab in command mode, it will be overridden. Thiscan be prevented by choosing a different value for the mapping keys, see the full documentation.
To disable this mapping, you can use the command:let g:latex_to_unicode_tab = "off"
, e.g. by puttingit into your.vimrc
file. You can also change this setting from the Vim command-line, but you willalso need to give the command:call LaTeXtoUnicode#Init()
for the change to take effect.
You can further fine-tune theg:latex_to_unicode_tab
option: to selectively enable theTabmapping only in the command line set it to"command"
, or set it to"insert"
to get the mapping onlyin insert mode. (The default setting is"on"
, which applies to both.)
Even when the mapping is disabled, the feature is still available (in insert mode) via thecompletion mechanism, i.e. by pressingCTRL-X and thenCTRL-U.
To disable the suggestions of partial matches completions, use the command:let g:latex_to_unicode_suggestions = 0
.
In general, suggestions try not to get in the way, and so if an exact match is detected (e.g.\ne
) whenTab is pressed, the substitution will be done even when there would be other symbols with the same prefix(e.g.\neg
). This behaviour can be changed by the command:let g:latex_to_unicode_eager = 0
, inwhich case hittingTab will first produce a suggestion list, and only pressing it again will trigger thesubstitution to Unicode.
The automatic remapping of theTab key is not performed if Vim version is lower than 7.4. However, thefunctionality can still be used via the completion mechanism, i.e. by usingCTRL-XCTRL-U. You canmap this to some more convenient key combination, e.g. you may want to add something like this line to your.vimrc
file:
inoremap <C-Tab> <C-X><C-U>
This would map the functionality toCTRL-Tab. However, if you try to map this toTab, you'd only beable to use literalTab by usingCTRL-VTab.
An automatic substitution mode can be activated by using the command:let g:latex_to_unicode_auto = 1
,e.g. by putting it into your.vimrc
file. You can also change this setting from the Vim command-line, butyou will also need to give the command:call LaTeXtoUnicode#Init()
for the change to take effect.
In this mode, symbols will be substituted as you type, as soon as some extra character appears after the symboland a LaTeX sequence can unambiguously be identified.
For example, if you typea \ne b
the\ne
will be changed to≠
right after the space, before you inputtheb
.
This does not interfere with theTab mapping discussed above. It only works in insert mode, and itdoesn't work with emojis.
This feature is not available with Vim versions lower then 7.4.
A different susbstitution mode based on keymaps can be activated with:let g:latex_to_unicode_keymap = 1
,e.g. by putting it into your.vimrc
file. This works similarly to the as-you-type method described above,but it has the advantage that it works under more circumstances, e.g. in command-line mode when searching with/
or?
, and when using thef
andt
commands.The main disadvantage is that you don't see the whole sequence as you're typing it, and you can't fix mistakeswith backspace, for example.Another difference is that there is a timeout like for any other mapping.In any case, it is possible to use this method in parallel with the other two methods, they don't interfere.So if you have theTab mapping (discussed above) activated, you still get to see completions andsuggestions. If you have the as-you-type substitution active, and you make a mistake, you can simply pressbackspace and keep going, at least in insert mode, and so on.
This feature might with Vim versions lower then 7.4, but it hasn't been tested.
By default, the LaTeX-to-Unicode substitutions are only active when editing Julia files. However, you can usethe variableg:latex_to_unicode_file_types
to specify for which file types this feature is active by default.The variable must be set to a string containing a pattern (a regular expression) which matches the desired filetypes, or to a list of such patterns. For example, to activate the feature on all file types, you could putlet g:latex_to_unicode_file_types = ".*"
in your.vimrc
file.Be aware, however, that enabling the functionality overrides thecompletefunc
setting.
Regardless of the type of the file you are editing and of theg:latex_to_unicode_file_types
setting, theLaTeX-to-Unicode substitutions can be enabled/disabled/toggled by calling the functionsLaTeXtoUnicode#Enable()
,LaTeXtoUnicode#Disable()
,LaTeXtoUnicode#Toggle()
. For example, you could usethe mappings:
noremap <expr> <F7> LaTeXtoUnicode#Toggle()noremap! <expr> <F7> LaTeXtoUnicode#Toggle()
and then use theF7 key to quickly turn the feature on and off.
This plug-in defines mappings to move around julia blocks (e.g.if/end
,function/end
etc.) and tomanipulate them as a whole (analogously to the standardw
,b
etc. commands to move on words, and totheaw
,iw
commands which allow to manipulate them). These require thematchit
plugin, which is usuallydistributed with ViM but must be explicitly enabled, e.g. adding this to your.vimrc
file:
runtime macros/matchit.vim
The default mappings use]]
,][
,[[
,[]
,]j
,]J
,[j
, and[J
for the movementsandaj
,ij
for the selections. These can be disabled collectively by settingg:julia_blocks
to0
,or they can be remapped and/or disabled individually by defining ag:julia_blocks_mapping
variable.See the documentation for details.
Note that this feature requires Vim version 7.4 or higher.
About
Vim support for Julia.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.