syntax highlight and indent awk code embedded in bash script?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

syntax highlight and indent awk code embedded in bash script?

Peng Yu
Hi,

I'm wondering if there is any plugin that can syntax highlight and
indent awk code embedded in bash script. By embedded I mean, some
thing like the following. The default bash plugin doesn't handle such
cases. It would be convenient if there is one.

awk 'awk expressions' file

Regards,
Peng

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: syntax highlight and indent awk code embedded in bash script?

Christian Brabandt
Hi Peng!

On Mi, 04 Apr 2012, Peng Yu wrote:

> Hi,
>
> I'm wondering if there is any plugin that can syntax highlight and
> indent awk code embedded in bash script. By embedded I mean, some
> thing like the following. The default bash plugin doesn't handle such
> cases. It would be convenient if there is one.
>
> awk 'awk expressions' file

:h sh-awk

this is only for syntax highlighting. I am not sure, if this is possible
for indentation scripts.

regards,
Christian

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: syntax highlight and indent awk code embedded in bash script?

Peng Yu
> :h sh-awk
>
> this is only for syntax highlighting. I am not sure, if this is possible
> for indentation scripts.

Hi Christian,

The above help page is not found in my vim. Is it available from some plugin?

--
Regards,
Peng

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: syntax highlight and indent awk code embedded in bash script?

Gary Johnson-4
On 2012-04-04, Peng Yu wrote:
> > :h sh-awk
> >
> > this is only for syntax highlighting. I am not sure, if this is possible
> > for indentation scripts.
>
> Hi Christian,
>
> The above help page is not found in my vim. Is it available from some plugin?

It's in the $VIMRUNTIME/doc/syntax.txt file for 7.3.187.  I don't
know when it was added.

Regards,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: syntax highlight and indent awk code embedded in bash script?

Gary Johnson-4
On 2012-04-04, Gary Johnson wrote:

> On 2012-04-04, Peng Yu wrote:
> > > :h sh-awk
> > >
> > > this is only for syntax highlighting. I am not sure, if this is possible
> > > for indentation scripts.
> >
> > Hi Christian,
> >
> > The above help page is not found in my vim. Is it available from some plugin?
>
> It's in the $VIMRUNTIME/doc/syntax.txt file for 7.3.187.  I don't
> know when it was added.

s/187/487/

Regards,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: syntax highlight and indent awk code embedded in bash script?

Peng Yu
On Wed, Apr 4, 2012 at 3:56 PM, Gary Johnson <[hidden email]> wrote:

> On 2012-04-04, Gary Johnson wrote:
>> On 2012-04-04, Peng Yu wrote:
>> > > :h sh-awk
>> > >
>> > > this is only for syntax highlighting. I am not sure, if this is possible
>> > > for indentation scripts.
>> >
>> > Hi Christian,
>> >
>> > The above help page is not found in my vim. Is it available from some plugin?
>>
>> It's in the $VIMRUNTIME/doc/syntax.txt file for 7.3.187.  I don't
>> know when it was added.
>
> s/187/487/
>
> Regards,
> Gary
>
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php

This is my vim version number. I'm not sure where is the number after
7.3 is. Is it 462?

$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Mar  4 2012 01:03:54)
MacOS X (unix) version
Included patches: 1-244, 246-462
Compiled by [hidden email]
Normal version without GUI.  Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent
-clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
-conceal +cryptv -cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path
+find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv
+insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
-mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse
+mouse_xterm -mouse_urxvt +multi_byte +multi_lang -mzscheme +netbeans_intg
+path_extra -perl +persistent_undo +postscript +printer -profile +python
-python3 +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
 -xterm_clipboard -xterm_save
   system vimrc file: "/opt/local/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/opt/local/share/vim"
Compilation: /usr/bin/gcc-4.2 -c -I. -Iproto -DHAVE_CONFIG_H
-I/opt/local/include -DMACOS_X_UNIX -no-cpp-precomp  -pipe -O2 -arch
x86_64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/gcc-4.2   -L/opt/local/lib -arch x86_64
-L/usr/local/lib -o vim       -lm  -lncurses -liconv -lintl -framework
Cocoa     -L/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config
-lpython2.7 -framework CoreFoundation -u _PyMac_Error
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python


--
Regards,
Peng

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: syntax highlight and indent awk code embedded in bash script?

Phil Dobbin
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/04/2012 22:02, Peng Yu wrote:

> On Wed, Apr 4, 2012 at 3:56 PM, Gary Johnson <[hidden email]> wrote:
>> On 2012-04-04, Gary Johnson wrote:
>>> On 2012-04-04, Peng Yu wrote:
>>>>> :h sh-awk
>>>>>
>>>>> this is only for syntax highlighting. I am not sure, if this is possible
>>>>> for indentation scripts.
>>>>
>>>> Hi Christian,
>>>>
>>>> The above help page is not found in my vim. Is it available from some plugin?
>>>
>>> It's in the $VIMRUNTIME/doc/syntax.txt file for 7.3.187.  I don't
>>> know when it was added.
>>
>> s/187/487/

> This is my vim version number. I'm not sure where is the number after
> 7.3 is. Is it 462?
>
> $ vim --version
> VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Mar  4 2012 01:03:54)
> MacOS X (unix) version
> Included patches: 1-244, 246-462
> Compiled by [hidden email]
> Normal version without GUI.  Features included (+) or not (-):

[snip]

That's odd. I have virtually the same OS X console Vim (7.3.462) & I too
have no help for sh-awk. However, MacVim (snapshot 54) on the same
machine does.

Cheers,

  Phil...

- --
But masters, remember that I am an ass.
Though it be not written down,
yet forget not that I am an ass.

        Wm. Shakespeare - Much Ado About Nothing


-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: §auto-key-locate cert pka ldap hkp://keys.gnupg.net
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPfLo4AAoJEKpMeDHWT5ADu8EH/20Ztrr7w/dcO9GmiUSPdnV1
J3HmueVg53xw+TO8596Wx6YBiBYh17e/NYG9wmXGOXq9ojrKO9Wxs00lRndJoQLu
y6eaFLDxfPF5e2vxaFAkYuWPcwVN1q19gKVpfNjxKthblxodVhD0vBfTwedE+TdX
gbRW9k/VO9Uv9+r15J76jcLzbFpHdlCUhShx4b83jD532DjICCKTi0d6kfGtXGPm
WzQ+T2TdnXRO37IlGMTSCoz+J7DsmjzrRceOmY05mp2GkPfJ14RJAEyWbpa0CdgT
W9xNjChvITUj5BpJ8GGWJKUEntGRhIf2Y9uYihyUXY9FStZlUgrTwasPrlbNpdc=
=hb/Q
-----END PGP SIGNATURE-----

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: syntax highlight and indent awk code embedded in bash script?

Christian Brabandt
In reply to this post by Gary Johnson-4
Hi Gary!

On Mi, 04 Apr 2012, Gary Johnson wrote:

> On 2012-04-04, Gary Johnson wrote:
> > On 2012-04-04, Peng Yu wrote:
> > > > :h sh-awk
> > > >
> > > > this is only for syntax highlighting. I am not sure, if this is possible
> > > > for indentation scripts.
> > >
> > > Hi Christian,
> > >
> > > The above help page is not found in my vim. Is it available from some plugin?
> >
> > It's in the $VIMRUNTIME/doc/syntax.txt file for 7.3.187.  I don't
> > know when it was added.
>
> s/187/487/

It's been in the VIMRUNTIME documentation since between patches 7.3.320
and 7.3.321
http://code.google.com/p/vim/source/detail?r=887d6d91882eb1d04509be76ab7e0454ebae8bb6

regards,
Christian
--

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: syntax highlight and indent awk code embedded in bash script?

John Little-4
In reply to this post by Peng Yu
On Thursday, April 5, 2012 9:02:43 AM UTC+12, Peng Yu wrote:

> This is my vim version number. I'm not sure where is the number after
> 7.3 is. Is it 462?

The run time files were not tracked by the patch system, in that no patches were released for updates, so it's not surprising your vim has out of date run-time files, but a recent patch level.  Things are better with mercurial.

Anyway, it's not that much (the lines starting "syn region" are 118 and 160 characters long):
                                                *sh-embed*  *sh-awk*
 Sh: EMBEDDING LANGUAGES~

You may wish to embed languages into sh.  I'll give an example courtesy of
Lorance Stinson on how to do this with awk as an example. Put the following
file into $HOME/.vim/after/syntax/sh/awkembed.vim: >

    " AWK Embedding: {{{1
    " ==============
    " Shamelessly ripped from aspperl.vim by Aaron Hope.
    if exists("b:current_syntax")
      unlet b:current_syntax
    endif
    syn include @AWKScript syntax/awk.vim
    syn region AWKScriptCode matchgroup=AWKCommand start=+[=\\]\@<!'+ skip=+\\'+ end=+'+ contains=@AWKScript contained
    syn region AWKScriptEmbedded matchgroup=AWKCommand start=+\<awk\>+ skip=+\\$+ end=+[=\\]\@<!'+me=e-1 contains=@shIdList,@shExprList2 nextgroup=AWKScriptCode
    syn cluster shCommandSubList add=AWKScriptEmbedded
    hi def link AWKCommand Type
<
This code will then let the awk code in the single quotes: >
        awk '...awk code here...'
be highlighted using the awk highlighting syntax.  Clearly this may be
extended to other languages.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: syntax highlight and indent awk code embedded in bash script?

Charles Campbell
In reply to this post by Peng Yu
Peng Yu wrote:
> Hi,
>
> I'm wondering if there is any plugin that can syntax highlight and
> indent awk code embedded in bash script. By embedded I mean, some
> thing like the following. The default bash plugin doesn't handle such
> cases. It would be convenient if there is one.
>
> awk 'awk expressions' file
>    

As far as syntax highlighting goes:  :help sh-embed

Regards,
Chip Campbell

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php