Saturday, April 8, 2017

Re: RFE: enable gvim to open a buffer or tab in a new window

Linda,

If you're willing to do some configuring, you can improve your
current workflow using Vim as it stands today, even if it only
approximates your desired layout of multiple top-level
application frames. Here are some quick suggestions; I'm sure
the list can provide help if you choose to pursue any of them.

- You can create Gvim menus for any of the commands that you've
seen suggested here, so you can use the mouse instead of the
keyboard.

- You can resize the top-level Gvim frame via ``:set columns``.
I do this all the time with two simple commands that take into
account line numbering and such. I call them ``:L1`` and
``:L2`` which give me one-column or two-column layouts fixed
at 80 columns. You can setup a menu that toggles your layout
based on whether you are looking at a tab with one file or a
tab with two files. Along with ``<c-w>=`` to automatically
balance the file width, you can automate the switching of your
views. I suspect you would never have to use the keyboard to
perform resizing if you analyze your use cases and script up
solutions for them, then create menus to activate them.

- You may want to take another look at tabs. In Gvim, you can
switch between tabs by clicking on the tab, instead of using
your desktop window manager to switch between Gvim instances.

There may be a plugin to present you with a menu of tabs to
choose from as well, or you could script that up if you found
you had too many tabs to easily see which one is which.

- You might also look into the Project plugin
(http://www.vim.org/scripts/script.php?script_id=69), which
gives you a menu of files in your project that you can select
from. This can help you reduce the amount of typing to select
a file.

- I use Derek Wyatt's "fswitch" plugin to switch between
"companion" files (as he puts it):
https://github.com/derekwyatt/vim-fswitch

If you have a .cc file open and you want to open the
corresponding .h file, fswitch can find it and open it for
you. There are other similar plugins to try as well.

- I greatly enjoy fuzzy file finders. I routinely use CtrlP
(https://github.com/ctrlpvim/ctrlp.vim.git) and LustyExplorer
(https://github.com/sjbach/lusty.git) to avoid having to type
all the characters in a filename. If you are trying to reduce
the amount of typing, you may want to consider such a plugin.

- Similarly, if you aren't already using tags, you may want to
consider installing Exuberant Ctags and generating a ``tags``
file for your entire project. I find this feature
indispensable for navigating through my codebase. When I want
to find the definition of a function, I just place my cursor
on the identifier in my current file and press a key; but in
Gvim, you can use the mouse to follow the tag as well, saving
keystrokes.

Michael Henry

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

Friday, April 7, 2017

Re: RFE: enable gvim to open a buffer or tab in a new window

Ben Fritz wrote:
>
> Is maximizing for the split view and then restoring the application window an option? If not is there a reason you need specifically 80-character application windows? Or do you just like that size?
>
----
I never use full screen unless I'm not doing work (movies/games).
80-chars -- many projects require lines to fit in an 80-char
width. It's a standard in the software world (not so much in the web
world).

And there's the final 'rub'... I'll try the other commands
you mention -- but I gave 1 example (that can't even be
handled w/80 column widths). When I'm working on a project
with >50 file-pairs, working to resize any of them manually is a
pain -- thus my comment that it was easier to quite and restart both
files in separate 80 column windows (FYI -- my window columns are
adjusted for the line numbers, automatically, so if a file has
line numbers turned on in the header, a vim-function takes care of
resizing the windows wider to handle the extra columns needed for
the numbering).

Also, side-by-side is one of the simplest to describe, but
many times, I'll have windows staggered so a quick click can
switch me to a different file. <<THAT is a major reason why
I don't use full screen. When I want to take a break or do
something else, I'll minimize my 13-vim edit buffs(6-w/2 tabs, +1),
or if it's a vid or game, just leave them for later. Also if
full screen I often won't see other application messages hidden
by the full screen window.

In your case (and Jacky's), using vim full-screen eliminates
even the thought of staggered windows or using the mouse to
arrange them. Full-screen narrows your view -- both in terms
of limiting it to only the files you've brought up, but also
to not seeing the usefulness of vim having multiple independent
windows as an option.

Do you use vimperator as well? (a vim-like extension that
used to be maintained for the FF web-browser. I tried it too,
BTW, but couldn't get used to using the keyboard to navigate
web pages.




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

Determine the exact word in many searched words

Hi,


While I search back to many possible keywords in my buffer with that :

let lineno = search('^\(FOO\|FOO_BLOCK\|BAR_BLOCK\|FOOBAR\)','bn')


Then would like to know in one code line with maybe "map(", "matchstr(v:val", the exact word found.


FOO

searching backward and then exact word is FOO

END_FOO

FOO_BLOCK

searching backward and then exact word is FOO_BLOCK

END_FOO_BLOCK


thanks

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

Re: execute sub command without moving cursor

Le jeudi 6 avril 2017 17:33:15 UTC+2, Ben Fritz a écrit :
> On Wednesday, April 5, 2017 at 4:56:06 PM UTC-5, ZyX wrote:
> > 2017-04-05 22:21 GMT+03:00 Ni Va <nivaemail@gmail.com>:
> > > Hi,
> > >
> > >
> > > I use this kind of command but it moves my cursor pos.
> > >
> > >
> > > silent! exe '?^BEGIN?,/^END/s/^NETWORK.*$/\="NETWORK".s:inc()." \/\/In ".s[0]." : ".s[1]/e'
> > >
> > >
> > > Can I avoid to move cursor when I replace executing sub command ?
> > > Thanks
> > > niva
> >
> > You can restore it afterwards: use winsaveview()+winrestview().
> > Otherwise you will have to emulate `:substitute` with search() and
> > setline() and this is going to be way too tricky.
> >
>
> Depending on what you're trying to do, winsaveview()/winrestview() may be overkill and a simple `` in normal mode may suffice. Or ma/`a.
>
> Although maybe I should map something to winsaveview()/winrestview() one of these days...

Then I wrote this little code :

function! s:getPatternCount(begL,endL,pattern)
let netrkC = 0
if copy(a:begL) < copy(a:endL)
for lnum in range(copy(a:begL), copy(a:endL))
if stridx(copy(getline(lnum)), copy(a:pattern)) == 0
let netrkC += 1
endif
endfo
endif
return netrkC
endfu
let networkCount = s:getPatternCount(copy(s:getPreviousLineBlock()), v:beval_lnum, 'NETWORK')

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

Re: count-items

Le vendredi 7 avril 2017 20:31:20 UTC+2, Christian Brabandt a écrit :
> Hi Ni!
>
> On Fr, 07 Apr 2017, Ni Va wrote:
>
> > Is it possible to use this kind of command to count items without moving cursor ?
> >
> > 'a,'bs/pattern//gn
>
> like the other question you asked about the :s command, this is not
> possible without wrapping into a function and saving/restoring the
> cursor position there.
>
>
> Best,
> Christian
> --
> Gute Manieren bestehen aus lauter kleinen Opfern.
> -- Ralph Waldo Emerson

Then I wrote this little code :

function! s:getPatternCount(begL,endL,pattern)
let netrkC = 0
if copy(a:begL) < copy(a:endL)
for lnum in range(copy(a:begL), copy(a:endL))
if stridx(copy(getline(lnum)), copy(a:pattern)) == 0
let netrkC += 1
endif
endfo
endif
return netrkC
endfu
let networkCount = s:getPatternCount(copy(s:getPreviousLineBlock()), v:beval_lnum, 'NETWORK')

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

Re: count-items

Hi Ni!

On Fr, 07 Apr 2017, Ni Va wrote:

> Is it possible to use this kind of command to count items without moving cursor ?
>
> 'a,'bs/pattern//gn

like the other question you asked about the :s command, this is not
possible without wrapping into a function and saving/restoring the
cursor position there.


Best,
Christian
--
Gute Manieren bestehen aus lauter kleinen Opfern.
-- Ralph Waldo Emerson

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

count-items

Hi,

Is it possible to use this kind of command to count items without moving cursor ?

'a,'bs/pattern//gn



Thanks

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