Editing iSeries source members with the Vim text editor

Why Vim

Because I like it smile Back when I used Windows I used the excellent TextPad editor, but it didn't work very well under Wine, and is GUI based. I wanted an editor equally at home in a console and on the desktop. Vim seemed easier to understand than Emacs, and I've stuck with it since then. I used to use remote command on the AS/400 to send a text version of source members to TextPad for editing, and swapped the technique to use Vim on Linux. If you're interested in the programs & commands I use to do this, let me know and I'll see if I can get them suitable for download. Using Vim in diff mode with two source members is far easier than SEU's split screen smile And speaking of merging changes, Meld is excellent too, btw.

Getting Vim

You can download Vim for just about every computing platform (except native iSeries!)

Syntax checking

Although Vim comes with syntax files for dozens of languages, RPG and friends aren't among them. I started work on one for RPG, didn't get very far and asked on-line for help. I was given a template to work with from someone on the vim-users list, and got a bit further, but still not much use frown I was then contacted by another Linux user and RPG programmer, Marc Mims, and (with mainly his code) we got a basic syntax file together. Once I understood the technique I expanded on that, and created files for DDS and RPGLE (RPGIV, not free-format). The REXX syntax file works very well for CL code, so I adapted that to work with common CL commands.

A little while later Scott Klement started a thread on the RPG400-L mailing list over at Midrange.com site. We swapped syntax files though in the end we stuck with our originals. I've continued to tweak the syntax files, but haven't spent much time on them in the last year or so.

Recognising iSeries code files

My download routine appends the member type as the file extension, so that's what I use to trigger the correct syntax file in Vim. I have a ~/.vim/filetype.vim file with these lines:
" my filetype file
augroup filetypedetect
  au! BufRead,BufNewFile *.rpg          setfiletype rpg
  au! BufRead,BufNewFile *.rpgle        setfiletype rpgle
  au! BufRead,BufNewFile *.clp          setfiletype clp
  au! BufRead,BufNewFile *.dspf         setfiletype dds
  au! BufRead,BufNewFile *.prtf         setfiletype dds
  au! BufRead,BufNewFile *.pf           setfiletype dds
  au! BufRead,BufNewFile *.lf           setfiletype dds
augroup END
and ~/.vim/mysyntax.vim to load those filetypes
au! Syntax rpg          so ~/.vim/rpg.vim
au! Syntax rpgle        so ~/.vim/rpgle.vim
au! Syntax clp          so ~/.vim/clp.vim
au! Syntax dds          so ~/.vim/dds.vim
and these lines in my ~/.vimrc
syntax on
set filetype=on
so ~/.vim/mysyntax.vim

See below for the syntax files.

  • dds.vim: DDS (DSPF, PRTF, PF, LF) syntax file for Vim

  • rpg.vim: RPG (RPG400) syntax file for Vim

  • rpgle.vim: RPGLE (RPGIV) syntax file for Vim
Topic attachments
I Attachment Action Size Date Who Comment
clp.vimvim clp.vim manage 4.5 K 01 Oct 2014 - 19:36 MartinRowe CLP syntax file for Vim
dds.vimvim dds.vim manage 2.0 K 01 Oct 2014 - 19:36 MartinRowe DDS (DSPF, PRTF, PF, LF) syntax file for Vim
rpg.vimvim rpg.vim manage 2.2 K 01 Oct 2014 - 19:36 MartinRowe RPG (RPG400) syntax file for Vim
rpgle.vimvim rpgle.vim manage 5.4 K 01 Oct 2014 - 19:36 MartinRowe RPGLE (RPGIV) syntax file for Vim
Topic revision: r4 - 01 Oct 2014 - 19:36:59 - UnknownUser
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding DBG/400? Send feedback