How to copy - word under cursor and filename with full path to clipboard.

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

How to copy - word under cursor and filename with full path to clipboard.

Sanjeev Sapre


Hello List,
I am looking for help on how to copy

1. Word under cursor
2. Current file name with full path to clipboard.

I would preferably map this to certain keys which will be handy.

Please give me hints on how I can do this.

Regards
Sanjeev

Reply | Threaded
Open this post in threaded view
|

Re: How to copy - word under cursor and filename with full path to clipboard.

Jürgen Krämer

Hi,

Sanjeev Sapre wrote:
>
> I am looking for help on how to copy
>
> 1. Word under cursor

  nmap <F4> :let @* = expand('<cword>')<cr>

> 2. Current file name with full path to clipboard.

  nmap <F5> :let @* = expand('%:p')<cr>

> I would preferably map this to certain keys which will be handy.

Regards,
J?rgen

--
J?rgen Kr?mer                              Softwareentwicklung
HABEL GmbH & Co. KG                        mailto:[hidden email]
Hinteres ?schle 2                          Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-Weilheim                    Fax: +49 / 74 61 / 93 53 - 99
Reply | Threaded
Open this post in threaded view
|

Re: How to copy - word under cursor and filename with full path to clipboard.

Tim Chase-2
>>1. Word under cursor
>
>   nmap <F4> :let @* = expand('<cword>')<cr>

In addition to Jurgen's suggestion, you can modify that to

nmap <f4> "*yiw

or

nmap <f4> "*yiW

if you want the non-whitespace definition of a "word".  Both are
a bit shorter.  Though thinking about it, they may also move the
cursor to the beginning of the word, and I think Jurgen's
solution keeps the cursor position.  More fodder for play :)

-tim




Reply | Threaded
Open this post in threaded view
|

Re: How to copy - word under cursor and filename with full path toclipboard.

R. shankar
Tim Chase wrote:

>
> >>1. Word under cursor
> >
> >   nmap <F4> :let @* = expand('<cword>')<cr>
>
> In addition to Jurgen's suggestion, you can modify that to
>
> nmap <f4> "*yiw
>
> or
>
> nmap <f4> "*yiW
>
> if you want the non-whitespace definition of a "word".  Both are
> a bit shorter.  Though thinking about it, they may also move the
> cursor to the beginning of the word, and I think Jurgen's
> solution keeps the cursor position.  More fodder for play :)
>
> -tim
Hi ,
I thought instead of quotestar, quoteplus must be used.
As per help, quotestar is used for portion selected by mouse or in visual mode.
quoteplus is used to copy the contents to the clipboard.

I also tested it. When selected a block of text using "*y, then it is available via mouse middle click to paste it but not through CTRL-V
When I selected using "+y, then I could paste by CTRL-V and not by middle clicking the mouse.

Am I correct in my understanding???

Regards,
shankar
Reply | Threaded
Open this post in threaded view
|

Re: How to copy - word under cursor and filename with full path toclipboard.

Tim Chase-2
> I thought instead of quotestar, quoteplus must be used.

I can't say I understand the intricate differences between the
two...I only use the system clipboard on Win32 where the two are
one and the same.  On my *nix platforms, it's always vim rather
than gvim, so I've not had to mess with which is which there.  My
feeble understanding (from ":help quotestar") is that X has
multiple clipboards...a primary selection which is what gets
pasted when you middle-click, and which gets overwritten whenever
you highlight something in your applications; a secondary
selection which (g)vim ignores; and a clipboard selection, which
gets used like its analog on the Win32 side of things (ctrl+x/c/v
for cut/copy/paste).  YMMV.

-tim





Reply | Threaded
Open this post in threaded view
|

RE: How to copy - word under cursor and filename with full path to clipboard.

David Fishburn
In reply to this post by Sanjeev Sapre
 

> -----Original Message-----
> From: Sanjeev Sapre [mailto:[hidden email]]
> Sent: Tuesday, June 28, 2005 1:26 AM
> To: [hidden email]
> Subject: How to copy - word under cursor and filename with
> full path to clipboard.

> I am looking for help on how to copy
>
> 2. Current file name with full path to clipboard.

I keep the following in my .vimrc:

" Copy the filename of the current buffer into the clipboard
" http://vim.sourceforge.net/tip_view.php?tip_id=296
if has('win32')
    nnoremap <Leader>ff :let @*=substitute(expand("%:p"), "/", "\\",
"g")<cr>
else
    nnoremap <Leader>ff :let @*=expand("%:p")
endif

The first switches the slashes to make it more useful on the windows
platform.

HTH,
Dave

--
Do you use Vim to edit SQL?
<Plug>
Check the description of these plugins:
dbext.vim - Provides database access to 10 databases (Oracle, Sybase, SQL
Server, MySQL,...) (http://www.vim.org/scripts/script.php?script_id=356)
SQLUtilities - Formatting SQL, generate - columns lists, procedures for
databases (http://www.vim.org/scripts/script.php?script_id=492)
sql.vim - SQL indent file for Sybase ASA and Oracle
(http://www.vim.org/scripts/script.php?script_id=495)
Intellisense for Vim : SQL, C++, CSharp, Java, JSP, XML, HTML
(http://www.vim.org/scripts/script.php?script_id=747)
</Plug>