|
Hi,
I'm wondering if there is a way to print the syntax highlighted text to stdout using ansi color. I was told the following trick to print the output to an html file. But I'd prefer the output to stdout. vim +'syn on | run! syntax/2html.vim | wq | q' foo.pl 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 |
|
On May 12, Peng Yu (Peng Yu) wrote:
>I'm wondering if there is a way to print the syntax highlighted text >to stdout using ansi color. I was told the following trick to print >the output to an html file. But I'd prefer the output to stdout. Yes, but let us do better than that and use all the available colors and text attributes, making the output to stdout identical to what you see in your vim session. I have this [0] aliased to cat, and when I don't want the highlighting, I just do a \cat file or =cat file instead. Here's a screenshot of what it looks like: http://devel.japh.se/vim-cat/vim_cat.png [0]: https://github.com/trapd00r/utils/blob/master/v -- Magnus Woldrich [hidden email], [hidden email] irc: scp1 on freenode uri: http://japh.se -- 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 |
|
On May 12, 6:47 pm, Magnus Woldrich <[hidden email]> wrote: > On May 12, Peng Yu (Peng Yu) wrote: > > >I'm wondering if there is a way to print the syntax highlighted text > >to stdout using ansi color. I was told the following trick to print > >the output to an html file. But I'd prefer the output to stdout. > > Yes, but let us do better than that and use all the available colors and text > attributes, making the output to stdout identical to what you see in your vim > session. > > I have this [0] aliased to cat, and when I don't want the highlighting, I just > do a \cat file or =cat file instead. > > Here's a screenshot of what it looks like:http://devel.japh.se/vim-cat/vim_cat.png > > [0]:https://github.com/trapd00r/utils/blob/master/v Would please show me how to use it? The figure is not very clear to me. I tried the following. But nothing happens. ~/dvcs_src/utils$ ./v v 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 |
|
In reply to this post by Magnus Woldrich
Wow, I've wanted this for a long time... I copied your script, and called it ccat, but get this (hope the attachment works)
-- 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 |
|
On Fri, Jun 29, 2012 at 9:08 PM, Dave <[hidden email]> wrote:
> Wow, I've wanted this for a long time... I copied your script, and called it ccat, but get this (hope the attachment works) How it works? In my previous email, I showed that I couldn't get it work. Would you please show me which command you copied and what is the command line? Thanks! -- 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 |
|
In reply to this post by Peng Yu
On Sat, 12 May 2012 20:11:07 -0700 (PDT), Peng Yu wrote:
> > > On May 12, 6:47 pm, Magnus Woldrich <[hidden email]> wrote: >> On May 12, Peng Yu (Peng Yu) wrote: >> >>> I'm wondering if there is a way to print the syntax highlighted text >>> to stdout using ansi color. I was told the following trick to print >>> the output to an html file. But I'd prefer the output to stdout. >> >> Yes, but let us do better than that and use all the available colors and text >> attributes, making the output to stdout identical to what you see in your vim >> session. >> >> I have this [0] aliased to cat, and when I don't want the highlighting, I just >> do a \cat file or =cat file instead. >> >> Here's a screenshot of what it looks like:http://devel.japh.se/vim-cat/vim_cat.png >> >> [0]:https://github.com/trapd00r/utils/blob/master/v > > Would please show me how to use it? The figure is not very clear to > me. > > I tried the following. But nothing happens. > > ~/dvcs_src/utils$ ./v v > Did you check the content of ./v? Is it the same with the online version? Did you chmod the script to add the execution bit? I just tried the latest version and it works for me. Just note that it has been renamed to `_v`. HTH -- alick Fedora 16 (Verne) user https://fedoraproject.org/wiki/User:Alick -- 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 |
|
> Did you check the content of ./v? Is it the same with
> the online version? Did you chmod the script to add the execution bit? > > I just tried the latest version and it works for me. > Just note that it has been renamed to `_v`. Obviously, I did what you have mentioned. ~/dvcs_src/utils$ ./_v _v ; echo xxx xxx I also tired to use the script by vim directly. ~/dvcs_src/utils$ vim -e -X -R "_v" -c "source _v" -c "visual" -c "bufdo call AnsiHighlight()" -c qa All I got was a flash of the screen (with non content) and then exit. So I guess may be related with my vim setup. Could anybody try the above command and let me know what you get? Thanks! My OS is Mac OS X snow leopard. ~/dvcs_src/utils$ vim --version VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 18 2012 01:05:44) MacOS X (unix) version Included patches: 1-244, 246-556 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 |
|
>MacOS X (unix) version
>Compiled by [hidden email] I'm sorry but the only thing I know about terminals in macos is that they doesn't work. Can you try it in something that is not terminal.app or iterm? Something like an xterm. VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 29 2012 19:25:34) Included patches: 1-353 Compiled by wolly - Fri Jun 29 19:25:31 CEST 2012 Huge 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 +user_commands_lowercase +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup +X11 +xfontset -xim -xsmp +xterm_clipboard -xterm_save system vimrc file: "$VIM/vimrc" user vimrc file: "~/etc/vim/vimrc" 2nd user vimrc file: "$VIMRUNTIME/vimrc" 3rd user vimrc file: "~/.vimrc" stracing what's happening can be an idea, and maybe the -D flag for vim can be useful. Have you asked about your issue in the #vim channel on freenode? There's a lot of mac{,vim} users, so someone might have an idea. -- Magnus Woldrich [hidden email], [hidden email] irc: japh on freenode, oftc uri: http://japh.se -- 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 |
|
On Sun, Jul 1, 2012 at 11:14 AM, Magnus Woldrich <[hidden email]> wrote:
>> MacOS X (unix) version >> Compiled by [hidden email] > > > I'm sorry but the only thing I know about terminals in macos is that > they doesn't work. > > Can you try it in something that is not terminal.app or iterm? Something > like an xterm. _v with xterm doesn't work on my mac. But _v does work on my linux machine. I'm trying to understand _v better. Why fd 9 is used? Is it special to vim? exec 9<>"$tmpfile" It seems the vim command in _v writes to fd 9. When I try the following command, it indeed write the content of _v along with the ansi color code to output.txt /usr/bin/vim -e -X -R "_v" -c "source _v" -c "visual" -c "bufdo call AnsiHighlight()" -c qa 2>/dev/null 9>output.txt But the above code does not work on Mac. I tried with a number of file descriptors. But none of them work. So it seems the problem is to find a fd that works on Mac. Note that this seem to be related to my recent question. http://groups.google.com/group/vim_use/browse_thread/thread/5797aa7de679930 -- 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 |
| Powered by Nabble | Edit this page |
