Re: Selecting tag opens file in a new tab - how?

2007-03-10 Thread A.J.Mechelynck

Zarko Coklin wrote:

Is it possible to have a setup in .vimrc so that every
time I select tag either through "CTRL-]" or by
holding CTRL and pressing left mouse click to open a
new buffer in a new tab?

Regards,
Zarko Coklin


:map   :exe "tab stag" expand("")
:map   :exe "tab stag" expand("")

See
:help :tab
:help :stag
:help 

Note:
:tab wincmd ]
ought to work but doesn't.



Best regards,
Tony.
--
There once was an old man from Esser,
Who's knowledge grew lesser and lesser.
It at last grew so small,
He knew nothing at all,
And now he's a College Professor.


Re: How to paste without replace the content in buffer

2007-03-10 Thread A.J.Mechelynck

Peng Yu wrote:

Hi,

Suppose I want to replace "string1" with "string2" in a file from vim.

1. Highlight "string1" (in visual mode) and then type "y".
2. Highlight "string2" (in visual mode) and then type "p".

However, the problem with the above procedure is that "string2",
instead of "string1", is in buffer. That is if I highlight "string3"
and then type "p", "string3" will be replaced with "string2" instead
of "string1".

I'm wondering if there is any way to avoid change the content in the 
buffer?


Thanks,
Peng



First, a bit of terminology:

English terminology: "to replace A by B" means removing A and putting B in its 
place, not the opposite.


Vim terminology: A "buffer" contains a whole file being edited. Text being 
"yanked" (Vimspeak for "copied"), "deleted" ("cut") or "put" ("pasted") is 
held in "registers".


Then, how to do it:

To replace "string2" by "string1" in the (file) buffer while allowing repeated 
put of the same (memory) register:


1. Highlight "string1" in visual mode and hit y

"string1" is now in "" (the default register) but also in "0 (the yank 
register).

2. Highlight "string2" and hit p (or "0p )

"string1" replaces "string2" in the text; "string2" has now overwritten "" but 
not "0 ; it is also in "1 (the top register of the delete list).


3. Highlight "string3" and hit "0p

"string1" replaces "string3" in the text ; "string3" now overwrites "" but not 
"0 ; "string2" (the contents of "1 ) is also pushed to "2 , and "string3" goes 
into "1


You can use "0p any number of times that way, as long as you do not _yank_ 
something else.


Alternately, you can memorise something that you want to remember even over 
one or more yanks, by placing it in a named register ( "a through "z ):


"by
yanks into register b (also registers " and 0 )
"xd
deletes into register x (also registers " and 1 )
"qp
puts from register q

With yank and delete, using an uppercase letters appends to the register 
instead of replacing what is in it; with put, "a and "A are synonymous.


There are other registers: "/ the latest search pattern; "+ the clipboard; "_ 
the blackhole register (which is always empty; anything deleted to it is _not_ 
placed in any other register), etc.


See ":help copy-move" and the whole section 5 ("Copying and moving text") of 
that helpfile.


The contents of the registers can be remembered across Vim sessions by means 
of the viminfo file (see ":help viminfo").



Best regards,
Tony.
--
People who have what they want are very fond of telling people who
haven't what they want that they don't want it.
-- Ogden Nash


Selecting tag opens file in a new tab - how?

2007-03-10 Thread Zarko Coklin
Is it possible to have a setup in .vimrc so that every
time I select tag either through "CTRL-]" or by
holding CTRL and pressing left mouse click to open a
new buffer in a new tab?

Regards,
Zarko Coklin


 

Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.
http://farechase.yahoo.com/promo-generic-14795097


Re: How to paste without replace the content in buffer

2007-03-10 Thread fREW

I think that the best way to do this is just with registers.  So what
you would do is:
v"ay
v"ap

what this does is use the a register to yank to/put from.

For more info see :help y and :help p

On 3/10/07, Peng Yu <[EMAIL PROTECTED]> wrote:

Hi,

Suppose I want to replace "string1" with "string2" in a file from vim.

1. Highlight "string1" (in visual mode) and then type "y".
2. Highlight "string2" (in visual mode) and then type "p".

However, the problem with the above procedure is that "string2",
instead of "string1", is in buffer. That is if I highlight "string3"
and then type "p", "string3" will be replaced with "string2" instead
of "string1".

I'm wondering if there is any way to avoid change the content in the buffer?

Thanks,
Peng




--
-fREW


How to paste without replace the content in buffer

2007-03-10 Thread Peng Yu

Hi,

Suppose I want to replace "string1" with "string2" in a file from vim.

1. Highlight "string1" (in visual mode) and then type "y".
2. Highlight "string2" (in visual mode) and then type "p".

However, the problem with the above procedure is that "string2",
instead of "string1", is in buffer. That is if I highlight "string3"
and then type "p", "string3" will be replaced with "string2" instead
of "string1".

I'm wondering if there is any way to avoid change the content in the buffer?

Thanks,
Peng


Re: bind (map) F9 to make && !make run

2007-03-10 Thread A.J.Mechelynck

Rafal Maj wrote:

A.J.Mechelynck wrote:


:map  :wall  !clear ; make && make run

Method II: intermixing internal and external commands

:map  :wall  exe "!clear"  exe "make"  !make run

Note: Method II does not intercept the return status from the first make.

Method III (untested) try to fool bash

:map  :wall  exe "!clear"  make && make run


Hmm no, I ment to do following:

1. execute vim's command:  make
if the return code is zero (ok) then
2. execute vim's command: !make run





I don't know how to get the return status from the external make invoked by 
internal ":make".



Please use "Reply to List" or "Reply to All" (whichever is available on your 
mailer) in preference to "Reply to Sender".



Best regards,
Tony.
--
Contrary to popular belief, Unix is user friendly.
It just happens to be selective about who it makes friends with.
   -- Dave Parnas


visual problem

2007-03-10 Thread Simon Jackson

I have a problem when i am in visual mode and i have text highlighted.
Instead of being able to run a command, it just overwrites my selected
text instead. im sure its because of something in my vimrc but i just
cant pinpoint it, can anyone help?

P.S.: If anyone sees some errors in my vimrc or maybe how something
can be done more efficiently please let me know.

filetype on   " detect the type of file
filetype plugin indent on" enable filetype plugin
set nocompatible  " use VIM defaults (much better!)
set magic " change special characters used in search patterns
set history=1000  " How many lines of history to remember
set clipboard+=unnamed" turns out I do like is sharing windows clipboard
set viminfo+=!" make sure it can save viminfo
set gdefault  " Use 'g' flag by default with :s/foo/bar/

"*
" Folding
"*
"set foldmethod=indent
"au BufWinLeave * mkview
"au BufWinEnter * silent loadview

"*
" Backups
"*
set backup" make backup file
set backupdir=~/.vim/backup " where to put backup file
set directory=~/.vim/temp   " directory is the directory for temp file

"*
" Vim UI
"*
set backspace=2   " make backspace work normal
set showmode  " show mode at bottom of screen
set title " show title in console title bar
set number" show line numbers
set mousemodel=popup
set selectmode=mouse,key,cmd
set mouse=a" make sure mouse is used in all cases.
set mousemodel=extend " set the model of mouse
if has("gui_running")
  set guioptions-=T " removes gui toolbar
endif
set ruler " ruler display in status line
set wrapscan  " search around end of file
set textwidth=78  " max length of line for inserting text
if has("gui_running")
  colorscheme darkblue
  "set guifont=Lucida_Console:h8:cDEFAULT
else
  colorscheme marklar
endif
set background=dark   " adapt colors for background
syntax on " turn on syntax
au FileType helpfile set nonumber " no line numbers when viewing help
au FileType helpfile nnoremap  " Enter selects subject
au FileType helpfile nnoremap  " Backspace to go back
"au GUIEnter * simalt ~x

"*
" File Browsing
"*

"*
" Visual Cues
"*
set mat=5 " how many tenths of a second to blink
matching brackets for
set incsearch " search for text as you type
set hls   " highlight all search matches
if has("gui_running")
  "set lines=54 " lines tall
  "set columns=175   " 160 cols wide
endif
set so=10 " Keep 10 lines (top/bottom) for scope
set showmatch " show matching brackets

"*
" Text Formatting
"*
set autoindent" pressing return puts new line at same indention
set smartindent   " assumes coding indents
set shiftwidth=3  " shift width size
set expandtab " use spaces instead of tabs
set tabstop=3 " tabs take up 3 spaces

"*
" Abbreviations
"*
ab teh the

"*
" Ruby
"*
autocmd FileType ruby setlocal sts=2 et

"*
" CakePHP
"*
au BufNewFile,BufRead *.thtml setfiletype php

"*
" OmniComplete
"*
setlocal omnifunc=syntaxcomplete#Complete
set wildmenu
set wildmode=list:longest,full
highlight Pmenu guibg=black gui=bold


--
Simon Jackson
107 Austin Elaine St.
Georgetown, TX 78628
United States
1-832-386-5069
[EMAIL PROTECTED]


Re: input gets repeated when having a break in input mode

2007-03-10 Thread A.J.Mechelynck

Peter Nasholm wrote:

Thanks for the hint,

Indeed there seems to be something about what you suggest. At least, I get

:verbose au cursorhold
--- Auto-Commands ---
Hit ENTER or type command to continue

I will try to dig a little bit deeper into this to see if I find a
solution. However, there is nothing about cursorhold in my .vimrc
file.

/ Petern


For Insert mode, it is CursorHoldI (v7 only), not CursorHold. The above shows 
that you have no autocommands defined for the latter, but what about the former?



Note: Please use "Reply to List" (if you mailer has it) or "Reply to All", not 
"Reply to Sender": it's better to allow other Vim users than me to see what 
you say.



Best regards,
Tony.
--
There once was a lady from Exeter,
So pretty that men craned their necks at her.
One was even so brave
As to take out and wave
The distinguishing mark of his sex at her.


Re: bind (map) F9 to make && !make run

2007-03-10 Thread A.J.Mechelynck

Rafal Maj wrote:

How to map F9 key to following action:
1. run buildin make (!make)
2. run shell command "make run"


I tried:


map  :wall:!clear:make && !make run

but then the F9 key results in:

Press ENTER or type command to continue
g++ a.cpp -o a.elf -lboost_thread -s -pthread
/bin/bash: !make: command not found

so the "make" part works, but "!make run " fails... why is it so?






What is F2 mapped to? In the following I ignore it.

Whatever follows the internal "make" command is passed to bash as parameters, 
including in this case the exclamation mark.


Method I: run external make twice

:map  :wall  !clear ; make && make run

Method II: intermixing internal and external commands

:map  :wall  exe "!clear"  exe "make"  !make run

Note: Method II does not intercept the return status from the first make.

Method III (untested) try to fool bash

:map  :wall  exe "!clear"  make && make run


See
:help map_bar
:help :bar


Best regards,
Tony.
--
Every successful person has had failures but repeated failure is no
guarantee of eventual success.


Re: CTRL-Z makes vim to be minimized on windows

2007-03-10 Thread A.J.Mechelynck

Eric Leenman wrote:

Hi,

I have mapped CTRL-Z as u
I'm not sourcing mswin.vim, and also not behave as windows
CTRL-Z does most of the times the undo-function.

But why does it also does minimize the screen sometimes?

Rgds,
Eric


How did you remap Ctrl-Z ?

:map  u
or
:noremap  u

should work;

:nmap  u
or
:nnoremap  u

should leave Ctrl-Z to mean "suspend" when used in Visual mode; vice-versa for

:imap  u
or
:inoremap  u


Best regards,
Tony.
--
Schlattwhapper, n.:
The window shade that allows itself to be pulled down,
hesitates for a second, then snaps up in your face.
-- Rich Hall, "Sniglets"


Re: How to make inoremap 's filetype depend

2007-03-10 Thread A.J.Mechelynck

Eric Leenman wrote:

Hi,

How do you making inoremap filetype depend?
What I want is

if (filetype == vim) then
  inoremap @a   A
else if (filetype == c)
  inoremap @a   aa
else if (filetype == vhdl)
  inoremap @a   AAAaaa
else
  inoremap @a   aaaAAA
end if

Best regards,
Eric


autocmd FileType *
\ if "" == "vim"
\ | inoremap  @a A
\ | elseif "" == "c"
\ | inoremap  @a aa
\ | elseif "" == "vhdl"
\ | inoremap  @a AAAaaa
\ | else
\ | inoremap  @a aaaAAA
\ | endif

Notice that there is no "then" and that "elseif" and "endif" are single words. 
The initial backslashes are line-continuation marks; they require 'nocompatible'.


See
:help :autocmd
:help FileType
:help 
:help :if
:help :else
:help :elseif
:help line-continuation


Best regards,
Tony.
--
Liar, n.:
A lawyer with a roving commission.
-- Ambrose Bierce, "The Devil's Dictionary"


Re: command to indent file

2007-03-10 Thread A.J.Mechelynck

Vu The Cuong wrote:

In the path I often used command to indent my php file or C# file:
gg ... G
mean go to the top of file and indent code until the end of file.
But Unfortunately I forgot.
Could anyone tell me what I forgot?
Thanks






see
:help =



Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
100. The most exciting sporting events you noticed during summer 1996
was Netscape vs. Microsoft.


Re: visual selection and X11/xterm clipboard (vim7)

2007-03-10 Thread A.J.Mechelynck

Joel Brobecker wrote:

Hello fellow vimmers,

I am working on an x86-linux machine running Debian testing.
I have switched to vim7 soon after it came out, and it's been awesome.
There is just one thing that changed and causes me some trouble: When
I select a visual region, the text region gets copied into the X11
clipboard. My previous X11 selection gets overwriten.  With vim6,
it wasn't doing that. Or maybe it was just by pure luck that my vim6
wasn't doing it?

I would like to restore the previous behavior because it works much
better with my working habits. I very often select something in one
of my X11 windows, then goes to my mailer, hit reply, *delete* parts
of the message I'm quoting through selecting a visual region, and then
use mouse-middle-click to paste the X11 clipboard, and OUCH!
My selection has been overwriten by the selection what I just deleted!
I need to go back to my X11 app and reselect the block again :-(.

That's just the most frequent example of why I'd like to restore
the previous behavior.

I have searched the documentation and the internet, and so far I have
only found one lead: Rebuild vim from sources with -xterm_clipboard.
This seems to be working well, but the drawback of course is that
I am no longer able to use the vim binaries provided by Debian.

I was hoping that there would be a way of configuring vim to turn
xterm_clipboard off. Or maybe do something equivalent.

Any idea?

Thank you,


:set clipboard=

see ":help 'clipboard'"


Best regards,
Tony.
--
Oh, I am a C programmer and I'm okay
I muck with indices and structs all day
And when it works, I shout hoo-ray
Oh, I am a C programmer and I'm okay


Re: input gets repeated when having a break in input mode

2007-03-10 Thread A.J.Mechelynck

petern wrote:

Hi dear vim lovers.

When I type some text in input mode and for example go to make a coffee
without leaving the input mode, and then get back to my computer, vim has
exited input mode. That's OK. But what confuses me is that some parts of my
input has been repeated and been inserted twice to my document.

Has anyone experienced such behaviour? How do I get rid of it?


Vim ought to stay in Input mode until you exit Inmut mode yourself by hitting 
.


Do you have any autocommands for CursorHoldI ?

:verbose au CursorHoldI



Best regards,
Tony.
--
"A University without students is like an ointment without a fly."
-- Ed Nather, professor of astronomy at UT Austin


Re: after compile VIM 7.0, I get error in running it...

2007-03-10 Thread A.J.Mechelynck

lin q wrote:

Hi,
  I downloaded the vim 7.0 package to my RedHat Enterprise 3 machine.
I do not have administrator previlidge, so I setup the env like this:

export DESTDIR=
export prefix=

  Then I run
make
make install

  But when I run vim, /usr/local/bin/vim, I get this error:

Error detected while processing /home/linq/.vimrc:
line   10:
E484: Can't open file /usr/local/share/vim/syntax/syntax.vim
Press ENTER or type command to continue

  Line 10 of my vimrc is: syntax on

  I am wondering why it still goes to /usr/local to look for data
files. Is there a way I can control this?

  By the way, in throwing the above error message, VIM starts, but it
is not GUI mode even though I have -g in the command, is that because
of the above problem?

Thanks.


Uncomment line 858

#prefix = $(HOME)

in src/Makefile (IIUC, the runtime files will end up in 
$(prefix)/share/vim/vim70/ and, if exec-prefix is not set, the executable(s) 
will end up in $(prefix)/bin/, which should be in the $PATH.)


then, set your configure options and

cd src
make reconfig > ../make.log 2>&1
ls -l vim
./vim --version |more

and, if the last two look OK,

make install


Best regards,
Tony.
--
I have yet to see any problem, however complicated, which, when looked
at in the right way, did not become still more complicated.
-- Poul Anderson


Re: HTML and tidy

2007-03-10 Thread Kevin Old

On 3/9/07, Simon Jackson <[EMAIL PROTECTED]> wrote:

Is it possible to use tidy to clean up my html in the current document?



Hi Simon,

Yes, this can be done.  Here's a vim tip
(http://www.vim.org/tips/tip.php?tip_id=18) that explains the process.
Scroll to the bottom to the last comment that explains it the best.

HTH,
Kevin

--
Kevin Old
[EMAIL PROTECTED]


bind (map) F9 to make && !make run

2007-03-10 Thread Rafal Maj

How to map F9 key to following action:
1. run buildin make (!make)
2. run shell command "make run"


I tried:


map  :wall:!clear:make && !make run

but then the F9 key results in:

Press ENTER or type command to continue
g++ a.cpp -o a.elf -lboost_thread -s -pthread
/bin/bash: !make: command not found

so the "make" part works, but "!make run " fails... why is it so?





Re: help with viki - :VikiMode does not work

2007-03-10 Thread Thomas

But If I want to create a New file if I hit CTRL + Return
when I am over CamelCaseWord with the cursor.


That's because viki isn't enabled for the new buffer. It has to be set 
for every buffer.



If I want to active :VikiMode nothings happens. No highlightning of
Headings, list, CamelCase, ... 


Is this the same buffer, in which you did :VikiMinorMode before? In this 
case, a variable b:vikiEnabled is set that would make :VikiMode exit 
before doing anything else. Try :set ft=viki.


Regards,
Thomas.



Re: Automatically positioning cursor when opening a file

2007-03-10 Thread Luc Hermitte
Hello James,

* On Fri, Mar 09, 2007 at 10:22:22AM +0100, James Kanze <[EMAIL PROTECTED]> 
wrote:
> I'm having trouble automatically positionning the cursor when
> opening an existing file.
> 
> Basically, all of my files have a standard header (copyright
> blurb, etc.), and I'd like to have the cursor positionned after
> it at the start of editing.  When opening a new file, I have the
> following in my .vimrc:
> 
> [...]
> 
> I'd like something similar when I open the file, but
> 
>autocmd BufReadPost *.cc,*.hh,*.sh,*.mk,GNUmakefile :1
>autocmd BufReadPost *.cc,*.hh,*.sh,*.mk,GNUmakefile /^$/
> 
> leaves the cursor at the top.

I have no idea why BufReadPost is not triggered. Could it be that your
autocommands are in the global scope, and that they are reset by other
autocommands which are triggered just before yours ?
You can try the following code to fix this possible situation
augroup JK_template
   au!
   au BufReadPost your auto-command
aug END

> Changing the event to BufWinEnter or BufEnter works well when I open
> the file, but causes the cursor position to be lost if I leave the
> window, then later come back to it.

If that case, you can set a buffer-local variable that tells you to not
reset the cursor position.
->
   function s:GotoLastEmptyLine() 
  if ! exist('b:JK_file_already_opened')
  normal! G
  let l = search('^\s$$','b')
  if l==0
 " do whatever you want
  endif
  let b:JK_file_already_opened =1
  endif
   endfunction

   au BufEnter *.cc call s:GotoLastEmptyLine()


> From the documentation, I'd expect BufReadPost to work, but it
> doesn't.
> 
> Also, while I'm at it: is there any reason why 1G doesn't work, but :1
> does, to start from a known point.

Auto-commands are expecting a command, not a normal mode sequence. Try
``:normal! 1G'' instead of ``1G''

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: How to make inoremap 's filetype depend

2007-03-10 Thread Luc Hermitte
Hello,

* On Sat, Mar 10, 2007 at 07:59:21AM +, Eric Leenman <[EMAIL PROTECTED]> 
wrote:
> How do you making inoremap filetype depend?
> What I want is
> 
> if (filetype == vim) then
>   inoremap @a   A
> else if (filetype == c)
>   inoremap @a   aa
> else if (filetype == vhdl)

I use ftplugins, and buffer local mappings
->
  " {rtp}/ftplugin/vim/at_a.vim
  inoremap  @a A

  " {rtp}/ftplugin/c/at_a.vim

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: inoremap tips/examples (Was Re:add c/c++ snippets)

2007-03-10 Thread Luc Hermitte
Hi,

* On Wed, Mar 07, 2007 at 07:48:24PM +, Eric Leenman <[EMAIL PROTECTED]> 
wrote:
> Triggered by the video presentation of Bram by making a iabbreviation
> or inoremaps of things you type often in combination with the reply of
> Gavin, would you like to share some of your inoremap mappings?
> Some like Gavin send?
> Plain and simple and very effective.

Few of mine are that simple -- I try to make them smart. However they
are quite effective. 
They can be found in the various ftplugins and some of the plugins I'm
maintening

Explore the tarballs in


HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


help with viki - :VikiMode does not work

2007-03-10 Thread J. Erik Heinz
Hi list,

new to the list. 
work on ubuntu 6.10, vim7 with patches 1-35

Have some problem with viki 
http://www.vim.org/scripts/script.php?script_id=861

I extracted viki.zip into my ~/.vim. Just mulitvals.vim ist additional 
installed, otherwise there are no other vim configuration files. 
A .vimrc is as well not definied. 

If I open my testfile with 
vim .viki/test.viki 
and active :VikiMinorMode the CamelCase words will be highlighted
correctly. But If I want to create a New file if I hit CTRL + Return
when I am over CamelCaseWord with the cursor. The cursor jumps only to
the next line. 

If I want to active :VikiMode nothings happens. No highlightning of
Headings, list, CamelCase, ... 

Some suggestions. I dont know how to debug or where to start. 

Cheers -- Erik 

-- 
J. Erik Heinz
Keyboard-samuraing in process

:: All non-mailinglist mail to this emailadress will be deleted.



Re: How to make inoremap 's filetype depend

2007-03-10 Thread Joel Brobecker
> How do you making inoremap filetype depend?
> What I want is
> 
> if (filetype == vim) then
>   inoremap @a   A
> else if (filetype == c)
>   inoremap @a   aa
> else if (filetype == vhdl)
>   inoremap @a   AAAaaa
> else
>   inoremap @a   aaaAAA
> end if

untested, but would the following work?

au FileType vim inoremap @a 

-- 
Joel


CTRL-Z makes vim to be minimized on windows

2007-03-10 Thread Eric Leenman

Hi,

I have mapped CTRL-Z as u
I'm not sourcing mswin.vim, and also not behave as windows
CTRL-Z does most of the times the undo-function.

But why does it also does minimize the screen sometimes?

Rgds,
Eric

_
Find what you need at prices you’ll love. Compare products and save at MSN® 
Shopping. 
http://shopping.msn.com/default/shp/?ptnrid=37,ptnrdata=24102&tcode=T001MSN20A0701