sponsor Vim development Vim logo Vim Book Ad

KRL-Syntax : Syntax, indent and more for Kuka industrial robots

 script karma  Rating 71/23, Downloaded by 4742  Comments, bugs, improvements  Vim wiki

created by
Patrick Meiser-Knosowski
script type
Now available on github: https://github.com/KnoP-01/krl-for-vim

KRL for Vim (7.4 or later) is a collection of Vim scripts to help programing KUKA industrial robots.

It provides

* syntax highlighting,
* support for commentary vimscript#3695 and matchit vimscript#39,
* auto indention,
* folding,
* mappings and settings to navigate through code in a backup folder structure,
* Text objects for functions and folds and
* mappings to insert a body of a new DEF, DEFFCT or DEFDAT based on user defined templates or hopefully sane defaults.

Since version 2.0.0 most features are enabled by default, so you don't need that many options in your .vimrc. Existing mappings don't get overridden, unless the corresponding option is explicitly set. There are <plug>-mappings available too, in case you prefer different key bindings.

KRL for Vim supports viewing and analysing VKRC files. Folding will get optimized for VKRC and you can use your Go Definition mapping (default gd) on a SPSMAKRO, UP, bin, binin or Marker in a fold line. However, this is NOT a VKRC-Editor.

Note: Keep your files to be edited in one folder or in a regular robot backup folder structure. KRL for Vim modifies 'path' accordingly. Since version 2.0.0 KRC1 backups are supported too.
Note to Linux users: Keep your files to be edited on a FAT file system. Some features need the case insensitive file system to work properly.


Q: Since version 2.0.0 everything's weird. How so?
A: Most optional features are enabled by default now.

Q: I'm here to feed my kids, not to read. How do I get rid of stuff?
A: Disable stuff in your vimrc, see krl-options for details: >

    let g:krlAutoComment = 0 " don't continue comments with o, O or Enter
    let g:krlFormatComments = 0 " don't break comment lines automatically
    let g:krlCommentIndent = 1 " indent comments starting in 1st column too
    let g:krlSpaceIndent = 0 " don't change 'sts', 'sw', 'et' and 'sr'
    let g:krlKeyWord = 0 " don't treat $, # and & as word char
    let g:krlShortenQFPath = 0 " don't shorten paths in quickfix
    let g:krlFoldLevel = 0 " don't close any fold

Q: I did set g:krlFoldLevel=1 or 2 but folds are open after loading a .src file?!
A: Unfortunately the order matters: >

    syntax on                   " before filetype plugin on
    filetype plugin indent on   " after syntax on

Q: Folds are still open although I have syntax on and filetype on in the right order?!
A: Some plugin manager mess with those commands, so with vim-plug I had to redo this after plug#end(): >

    call plug#end()
    syntax off                 " undo what plug#begin() did to syntax
    filetype plugin indent off " undo what plugin#begin() did to filetype
    syntax on                   " before filetype plugin on
    filetype plugin indent on   " after syntax on

Q: Which keys get mapped to what?
A: If there is no existing mapping which would be overridden and no <plug> mapping is configured for that function then the following keys get mapped: >

    <F2> Switch folding off
    <F3> Close movement folds.
    <F4> Close all folds.
        Depend on g:krlFoldLevel not existing or >=1.
        Can be forced with
            let g:krlFoldingKeyMap = 1

    gd Go to or show definition of variable or def/deffct.
        Can be forced with
            let g:krlGoDefinitionKeyMap = 1

    <leader>u List all appearances of word under cursor outside a comment, string or enum declaration.
        Can be forced with
            let g:krlListUsageKeyMap = 1

    <leader>f List all def/deffct in the current file.
        Can be forced with
            let g:krlListDefKeyMap = 1

    [[ Move around functions. Takes a count.
    ]] Move around functions. Takes a count.
    [] Move around functions. Takes a count.
    ][ Move around functions. Takes a count.
    [; Move around comments. Takes a count.
    ]; Move around comments. Takes a count.
        Will override existing mappings!
        Can be forced off with
            let g:krlMoveAroundKeyMap = 0

    if Inner function text object.
    af Around function text object.
    aF Around function text object including preceding comments and one following empty line.
        Depend on g:krlMoveAroundKeyMap not existing or =1.
        Can be forced with
            let g:krlFunctionTextObject = 1

    io Inner fold text object. Takes a count for nested folds.
    ao Around fold text object. Takes a count for nested folds.
        Depend on matchit.
        Can be forced with
            let g:krlFoldTextObject = 1

    ic Inner comment text object.
    ac Around comment text object.
        Depend on g:krlMoveAroundKeyMap not existing or =1.
        Can be forced with
            let g:krlCommentTextObject = 1

    <leader>n Inserts a new def/deffct.
        Can be forced with
            let g:krlAutoFormKeyMap = 1

Q: Does krl-for-vim provide a mapping for indenting a complete file?
A: No, but you may put the following in your .vimrc or ~/.vim/after/ftplugin/krl.vim: >

    nnoremap ANYKEY gg=G``zz

Q: Does krl-for-vim provide a mapping to quickly switch between the corresponding dat- and src-file?
A: No, but you may put the following in your .vimrc or ~/.vim/after/ftplugin/krl.vim: >

    nnoremap <F1> :if expand('%')=~'\.dat$'
\<bar> e %:s?\.dat$?.src?
\<bar> else
\<bar> e %:s?\.src$?.dat?
\<bar> endif<CR>

Q: Scrolling feels sluggish. What can I do?
A: Switch error highlighting off and/or folding to marker: >

    let g:krlFoldMethodSyntax = 0 " better performance, but case sensitive
    let g:krlShowError = 0        " better performance

Q: Still sluggish!
A: Switch syntax off or jump instead of scroll!

Q: Where are the nice and informative messages?
A: :let g:knopVerbose=1 any time.

If you like this plugin please rate it. If you don't but you think it could be useful if this or that would be different, don't hesitate to email me or even better open an issue on github. With a little luck and good timing you may find me on irc://irc.freenode.net/#vim as KnoP in case you have any questions.
install details
### Installation with vim-plug:  ~
Put this in your .vimrc:  >

    call plug#begin('~/.vim/plugged')
      Plug 'KnoP-01/krl-for-vim'
    call plug#end()
    syntax off                        " undo what plug#begin() did to syntax
    filetype plugin indent off  " undo what plugin#begin() did to filetype
    syntax on                        " syntax and filetype on in that order
    filetype plugin indent on  " syntax and filetype on in that order

For the first installation run: >


Update every once in a while with: >


### Manual installation:  ~
Extract the most recent release and copy the folders `/doc`, `/ftdetect`, `/ftplugin`, `/indent` and `/syntax`  into your `~/.vim/` or `%USERPROFILE%\vimfiles\` directory. Overwrite krl.* files from older installation.
Put the following in your .vimrc: >

    syntax on                        " syntax and filetype on in that order
    filetype plugin indent on  " syntax and filetype on in that order

You may have to run >

    :helptags ~/.vim/doc/

or >

    :helptags ~/vimfiles/doc/

to use the help within Vim after installation. >

    :help krl

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
krl-for-vim-2.0.1.zip 2.0.1 2019-10-22 7.3 Patrick Meiser-Knosowski * Fix bug where unnamed buffers are created for each use of gd, <leader>f and <leader>u
* Fix fold text object
* Clarifications and fixes in documentation
krl-for-vim-2.0.0.zip 2.0.0 2019-04-29 7.4 Patrick Meiser-Knosowski * enable most features by default
* change default fold method to syntax to make it case insensitive
* add text objects for DEF/DEFFCT, folds and comment blocks
* [[, [], ... work in operator pending mode
* add support of KRC1 archives
krl-for-vim-1.5.5.zip 1.5.5 2017-12-08 7.4 Patrick Meiser-Knosowski * added more spline instructions
* added kss functions and data types
* highlight of vars and funcs >24 chars as error
* highlight of "interrupt <prio> on" as error
* fixed minor highlight bug
krl-for-vim-1.5.2.zip 1.5.2 2017-11-04 7.4 Patrick Meiser-Knosowski * changed highlight to highlight default in syntax file
* added channel to data types for gd
* fixed bug in ftdetext where a defdat was not recognized when there where two spaces between defdat and the name
* made KrlFormatComments() global again
* changes in help file
krl_for_vim_v151_20170813.zip 1.5.1 2017-08-13 7.4 Patrick Meiser-Knosowski * better path generation
* better temp file handling. Sorry to all linux/unix users for inconvenience with this one.
* made this script compatible to romainls vim-qf (vimscript#5211)
* fixed some minor bugs
krl_for_vim_v150_20170624.zip 1.5.0 2017-06-24 7.0 Patrick Meiser-Knosowski * improved vkrc support:
  * Go Definition now works on UP\d+, SPSMAKRO\d+ and M\d+ in fold lines
  * improved List Usage for vkrc
* fixed Go Definition for comma separated none value declarations in *.dat files
* fixed e6pos return var name in Auto Form
* fixed array function in Auto Form (e.g. deffct char[24] chName() )
krl_for_vim_v145_20170215.zip 1.4.5 2017-02-15 7.0 Patrick Meiser-Knosowski * fixed bug in matchit (vimscript #39) support
krl_for_vim_v144_20161128.zip 1.4.4 2016-11-28 7.0 Patrick Meiser-Knosowski * divided up mappings for <leader>f and gd into 2 options: g:krlListDefKeyMap and g:krlGoDefinitionKeyMap
* added option to influence where <leader>f and gd open the quickfix window: g:krlRhsQuickfix and g:krlLhsQuickfix
* added <plug> mappings as an alternative to the configuration variables for mappings
* minor changes in syntax file
* added auto form feature. Insert a body for a new deffct with a few key strokes. See help for more details on this
* added mapping <leader>u to list all appearances of the word under the cursor if g:krlListUsageKeyMap is set
krl_for_vim_v138_20161008.zip 1.3.8 2016-10-09 7.0 Patrick Meiser-Knosowski * changes in help file
krl_for_vim_v138_20161005.zip 1.3.8 2016-10-06 7.0 Patrick Meiser-Knosowski * set proper b:undo_indent and b:undo_ftplugin
* added matchit support (vimscript #39)
* added mappings for [[, ]], ... and gd if g:krlGoDefinitionKeyMap is set
* added 'path', 'suffixes' and 'suffixesadd' settings for :find or gf
* added 'iskeyword' to match $-variables and #-enums
* changed option name from g:krlNoHighlight to g:krlNoHighLink (the old one does still work for compatibility)
From 1.3.6 to 1.3.8
* reorganized 'path' for better search results of gd, :find ...
* optimized KrlGoDefinition()
* made embedded $ chars in variable names possible for gd. Embedded $ chars in DEF or DEFFCT names do still not work
* less noise if g:krlNoVerbose is set
* additions to syntax
* added mapping of <leader>f to list all DEF and DEFFCT of the current file if g:krlGoDefinitionKeyMap is set
krl_for_vim_v124_20160727.zip 1.2.4 2016-07-27 7.0 Patrick Meiser-Knosowski * fixed a bug where this script caused an error message about a missing function in some installations of vim
* added new highlight group Continue to be able to highlight continue instructions separately if g:krlNoHighlight is set
* this script now setlocal commentstring=;%s for easy use of commentary (vimscript #3695)
* restructured code
krl_for_vim_v120_20160604.zip 1.2.0 2016-06-03 7.0 Patrick Meiser-Knosowski * added option (g:krlShowError) to highlight some misuses of =, ==, <= and >=
* added ENABLE/DISABLE (interrupt enable ..) to keywords
krl_for_vim_v113_20160524.zip 1.1.3 2016-05-24 7.0 Patrick Meiser-Knosowski * added help
* added file type detect
* added file type plugin
* added indent file
* made the script configurable by options
* minor changes in syntax file
krl.vim 1.1.1 2016-04-15 7.0 Patrick Meiser-Knosowski I think I'm getting closer to how a syntax file is supposed to be done. I changed to much to list here. Depending on your colorscheme it might not look very different.
Main changes:
* fixed false highlighting for structure component names
* added more predefined enums and structures, also from some basic tech packages (BasisTech, GripperTech, SpotTech...)
* enum values are now considered Constant (no need for "highlight Enum ..." any more)
* devided stuff into sub groups
* added some missing build in functions
krl.vim 0.9 2016-03-07 7.0 Patrick Meiser-Knosowski Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
OSDN.net Logo