Friday, April 11, 2014

Troubles with perl script in Vim

Trying to set to status line current subname, using this manual
http://blogs.perl.org/users/ovid/2011/01/show-perl-subname-in-vim-statusline.html
First problem - when I put it on my vimrc I get error on vim start
line 11:
E126: Missing :endfunction
my vimrc is empty, I put there only script from manual page. If I don't
use <<EOP ... EOP got no errors. So I put so

function! WhitePearl()
perl 'use strict; sub current_sub {my $curwin = $main::curwin; my
$curbuf = $main::curbuf; my @document = map { $curbuf->Get($_) } 0 ..
$curbuf->Count; my ( $line_number, $column ) = $curwin->Cursor; my
$sub_name = \'(not in sub)\'; for my $i ( reverse ( 1 .. $line
_number -1 ) ) {my $line = $document[$i]; if ( $line =~
/^\s*sub\s+(\w+)\b/ ) { $sub_name = $1; last; }} VIM::DoCommand "let
subName=\'$line_number: $sub_name\'"; }; '
endfunction
call WhitePearl()

After this if i try to output variable subName vim prints Undefined
variable. Help me_)

my :version
:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 11 2014 05:00:10)
Compiled by negor@dev25
Huge version without GUI. Features included (+) or not (-):
+arabic -clipboard +cursorbind +eval
-footer +langmap +mksession +mouse_sgr
+path_extra +quickfix +startuptime +terminfo
+visual -X11
+autocmd +cmdline_compl +cursorshape +ex_extra
+fork() +libcall +modify_fname -mouse_sysmouse
+perl +reltime +statusline +termresponse
+visualextra -xfontset
-balloon_eval +cmdline_hist +dialog_con +extra_search
+gettext +linebreak +mouse +mouse_urxvt
+persistent_undo +rightleft -sun_workshop +textobjects
+viminfo -xim
-browse +cmdline_info +diff +farsi
-hangul_input +lispindent -mouseshape +mouse_xterm
+postscript -ruby +syntax +title
+vreplace -xsmp
++builtin_terms +comments +digraphs +file_in_path
+iconv +listcmds +mouse_dec +multi_byte
+printer +scrollbind +tag_binary -toolbar
+wildignore -xterm_clipboard
+byte_offset +conceal -dnd +find_in_path
+insert_expand +localmap -mouse_gpm +multi_lang
+profile +signs +tag_old_static +user_commands
+wildmenu -xterm_save
+cindent +cryptv -ebcdic +float
+jumplist -lua -mouse_jsbterm -mzscheme
-python +smartindent -tag_any_white +vertsplit +windows
-clientserver +cscope +emacs_tags +folding
+keymap +menu +mouse_netterm +netbeans_intg
-python3 -sniff -tcl +virtualedit +writebackup
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/home/negor/apps/vim/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/local/include -g
-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-E -L/usr/local/lib -Wl,--as-needed -o vim
-lm -ltinfo -lnsl -ldl -Wl,-E -fstack-protector -L/usr/local/lib
-L/usr/lib/perl/5.14/CORE -lperl -ldl -lm -lpthread -lcrypt

my uname -a
Linux negor 2.6.32-5-amd64 #1 SMP Mon Sep 23 22:14:43 UTC 2013 x86_64
GNU/Linux

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: