Showing posts with label free pascal compiler. Show all posts
Showing posts with label free pascal compiler. Show all posts

2010-03-10

Running Vim from Lazarus IDE

I would like to edit my program both in Lazarus IDE and Vim. Lazarus IDE is good, but Vim is faster for hard core text processing. Thanks to both of them, this task is easy.

First step is to launch Lazarus IDE, and selecting "Configure external tools ..." from the "Tools" menu.




Next step is trivial, just adding a new entry by clicking "Add".


In the final step, type the following information into specified fields.

Title: Edit with Vim

Program File Name: C:\PortableApps\PortableApps\gVimPortable\gVimPortable.exe

Parameters: +$Row() "$EdFile()"

Working Directory: $Path()

+$Row() allows Vim to directly locate the cursor when the file is opened so that you can keep going on, very useful for large files.

"$EdFile()" is the full path to the file. Note that this will work even though you have a single file on Lazarus, not a project. (If you want that, there are options for that too.)

$Path() is the working directory of the file. It will be useful to locate that directory so that you can easily open more files from Vim.


After all, your final screen should look like this:




You can now open a file from Lazarus IDE in Vim as follows:




Note that you should have a file opened it must be saved to appear in Vim.

2009-06-05

Delphi Pascal/Object Pascal editing in Vim

Here are a few Vim plugins for Pascal editing.

Compiler
fpc.vim : "Free Pascal Compiler" compiler plugin
It can already be bundled in your Vim. If it is not, you can download it. After opening a .pas file, type
:compiler fpc
Compiler plugins are not loaded automatically in Vim. You'll have to load them explicitly.

Syntax
Syntax file for Borlands Delphi/Kylix
Vim 7 is already bundled with Pascal syntax plugin. But Object Pascal is more than that. To colorize the keywords of Object Pascal, you can use this plugin which is derived from the original Pascal syntax plugin.

Note that although this plugin is a syntax file, if you look in the script, you will see that it also contains color codes. That is why you will not see the color scheme you selected if you have this plugin. To overcome this issue, you can delete the following lines from the delphi.vim :


261 hi pascalObject          ctermfg=white         guifg=white         gui=italic
262 hi pascalFunction        ctermfg=LightRed      guifg=Orange        gui=NONE
263 hi pascalStatement       ctermfg=Green         guifg=Green         gui=NONE
264 hi pascalNumber          ctermfg=LightBlue     guifg=LightBlue     gui=NONE
265 hi pascalByte            ctermfg=LightRed      guifg=LightRed      gui=bold
266 hi pascalString          ctermfg=LightBlue     guifg=LightBlue     gui=NONE
267 hi pascalMatrixDelimiter ctermfg=lightred      guifg=lightred      gui=NONE
268 hi pascalConditional     ctermfg=Green         guifg=Green         gui=NONE
269 hi pascalConstant        ctermfg=white         guifg=white         gui=NONE
270 hi pascalModifier        ctermfg=Green         guifg=Green         gui=NONE
271 hi pascalType            ctermfg=white         guifg=white         gui=NONE
272 hi pascalStructure       ctermfg=Green         guifg=Green         gui=NONE
273 hi pascalRepeat          ctermfg=Green         guifg=Green         gui=NONE
274 hi pascalOperator        ctermfg=Green         guifg=Green         gui=NONE
275 hi pascalAssignment      ctermfg=Magenta       guifg=Magenta       gui=NONE
276 hi pascalComment         ctermfg=LightBlue     guifg=#00A0A0       gui=italic
277 hi pascalLabel           ctermfg=Green         guifg=Green         gui=NONE
278 hi pascalDelimiter       ctermfg=Yellow        guifg=Yellow        gui=NONE
279 hi pascalComparator      ctermfg=Yellow        guifg=Yellow        gui=NONE

I should remind you that the colors are not bad though. Delete them if you want to use the color scheme selected; otherwise leave it as it is, it just works.
If you are curious, here is the screenshot of the colors provided by the syntax plugin:


Also the author of this plugin provides some code to be put on your .vimrc and it is quite useful.
This is the code to be put on your .vimrc:
 1 " Pascal / Delphi
 2 if (1==1) "change to 1==0 to use original syntax
 3   au BufNewFile,BufRead *.pas,*.PAS set ft=delphi
 4 else
 5   au BufNewFile,BufRead *.pas,*.PAS set ft=pascal
 6 endif
 7 " Delphi project file
 8 au BufNewFile,BufRead *.dpr,*.DPR set ft=delphi
 9 " Delphi form file
10 au BufNewFile,BufRead *.dfm,*.DFM set ft=delphi
11 au BufNewFile,BufRead *.xfm,*.XFM set ft=delphi
12 " Delphi package file
13 au BufNewFile,BufRead *.dpk,*.DPK set ft=delphi
14 " Delphi .DOF file = INI file for MSDOS
15 au BufNewFile,BufRead *.dof,*.DOF set ft=dosini
16 au BufNewFile,BufRead *.kof,*.KOF set ft=dosini
17 au BufNewFile,BufRead *.dsk,*.DSK set ft=dosini
18 au BufNewFile,BufRead *.desk,*.DESK set ft=dosini
19 au BufNewFile,BufRead *.dti,*.DTI set ft=dosini
20 " Delphi .BPG = Makefile
21 au BufNewFile,BufRead *.bpg,*.BPG set ft=make|setlocal makeprg=make\ -f\ %

Color Schemes
Delphi color scheme

Turbo color scheme

Borland color scheme