×
UNIX.COM Login
Username:
Password:  
Show Password






👤


UNIX for Beginners Questions & Answers

If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Vim tips and tricks

👤 Login to reply

 
Thread Tools Search this Thread Display Modes
    #8  
Old 04-28-2010
posix's Unix or Linux Image
posix posix is offline
Registered User
 
Join Date: Feb 2010
Last Activity: 16 May 2018, 7:03 AM EDT
Location: grep "Bhubaneswar" "india"
Posts: 192
Thanks: 8
Thanked 13 Times in 13 Posts
Bug How Copy upto first blank space

Hi,
I need to copy text up to first blank space in the line.


Code:
my_number=12345.6789% 1654.2345 This a sample line. 
I need to copy upto first.blank_space in this line.

Here my cursor is at m i need to copy upto first blank i.e my_number=12345.6789% to a register.similarly we go for second line here if cursor is at fthen i need first.blank_space to some other register.

Thanks
posix
Sponsored Links
    #9  
Old 05-08-2010
ungalnanban's Unix or Linux Image
ungalnanban ungalnanban is offline
Registered User
 
Join Date: Feb 2010
Last Activity: 21 November 2016, 4:44 AM EST
Location: Chennai
Posts: 142
Thanks: 5
Thanked 29 Times in 7 Posts
Shift + k is used to open the man page under the cursor. if you want to execute the command instead of opening the man page use the following functions.

"This function used to get the current cursor word and execute that command


Code:
                fu ExecuteCommand()
                let l:Command = expand("<cword>")
                execute "!" . l:Command
                endfu

"This function used to get the current cursor line and execute that command


Code:
                fu ExecuteCommandLine()
                let l:Command = getline(line("."))
                execute "!" . l:Command
                endfu

Note:
<cword> is replaced with the word under the cursor (like |star|)
<cWORD> is replaced with the WORD under the cursor (see WORD|)


---------- Post updated at 01:14 ---------- Previous update was at 01:08 ----------

Quote:
Originally Posted by posix View Post
Hi,
I need to copy text up to first blank space in the line.


Code:
my_number=12345.6789% 1654.2345 This a sample line. 
I need to copy upto first.blank_space in this line.

Here my cursor is at m i need to copy upto first blank i.e my_number=12345.6789% to a register.similarly we go for second line here if cursor is at fthen i need first.blank_space to some other register.

Thanks
posix

use the keys : 1yW


The Following 2 Users Say Thank You to ungalnanban For This Useful Post:
Neo (05-20-2010), posix (07-29-2010)
Sponsored Links
    #10  
Old 05-29-2010
ungalnanban's Unix or Linux Image
ungalnanban ungalnanban is offline
Registered User
 
Join Date: Feb 2010
Last Activity: 21 November 2016, 4:44 AM EST
Location: Chennai
Posts: 142
Thanks: 5
Thanked 29 Times in 7 Posts
MySQL

Underline a text/line in vim


Code:
nnoremap <F5> yyp<c-v>$r-
" <F5> underline a word or line

Example:

This is for Example

if you want to underline this above line use the above code then it will be like this.

This is for Example
--------------------
    #11  
Old 07-21-2010
frajer frajer is offline
Registered User
 
Join Date: Sep 2005
Last Activity: 20 March 2012, 8:23 AM EDT
Location: Slovenija
Posts: 41
Thanks: 1
Thanked 0 Times in 0 Posts
wq with dot

Be very careful when you quit with editing some file. I use the following ...


Code:
:wq

But ones one little dot came between ...


Code:
:.wq

Whot does it mean? It saves only the line where the cursor was at that moment.

That time I lost more than 12000 lines and about 2 hours and a half work. Only because a finger slides over a dot.
Sponsored Links
    #12  
Old 07-21-2010
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 8 July 2018, 4:41 PM EDT
Posts: 9,062
Thanks: 402
Thanked 1,279 Times in 1,082 Posts
Quote:
Originally Posted by frajer View Post
Be very careful when you quit with editing some file. I use the following ...


Code:
:wq

But ones one little dot came between ...


Code:
:.wq

Whot does it mean? It saves only the line where the cursor was at that moment.

That time I lost more than 12000 lines and about 2 hours and a half work. Only because a finger slides over a dot.
Great point, but iit should only allow it if you force a write with:



Code:
:.wq!

But it's easily done, especially if saving a read-only file, where you have to use ! anyway.
Sponsored Links
    #13  
Old 07-23-2010
royalibrahim royalibrahim is offline
Registered User
 
Join Date: Jun 2007
Last Activity: 22 November 2017, 3:56 AM EST
Posts: 353
Thanks: 56
Thanked 5 Times in 5 Posts
Hi,
I am using VIM 7.1 version on my Ubuntu 8.04 (hardy heron). I am irritated to see the auto matching cursor whenever it comes across parantheses, brackets and braces while editing. I used ':set noshowmatch', but no use. What other options are available for me?
Sponsored Links
    #14  
Old 07-23-2010
ungalnanban's Unix or Linux Image
ungalnanban ungalnanban is offline
Registered User
 
Join Date: Feb 2010
Last Activity: 21 November 2016, 4:44 AM EST
Location: Chennai
Posts: 142
Thanks: 5
Thanked 29 Times in 7 Posts
MySQL

set the following code in your .vimrc file



Code:
let g:loaded_matchparen= 1

The Following User Says Thank You to ungalnanban For This Useful Post:
royalibrahim (07-23-2010)
Sponsored Links
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Very Importan - Vim Settings - Error while opening a File using vim girija Solaris 0 08-13-2010 08:37 AM
Sed Tricks siba.s.nayak UNIX for Dummies Questions & Answers 3 10-20-2009 03:01 AM
Solaris tips and tricks solaris_user Post Here to Contact Site Administrators and Moderators 1 09-24-2009 01:02 PM



All times are GMT -4. The time now is 12:27 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.