Home Man
Search
Today's Posts
Register

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

Tags
beginners

Login to Reply

 
Thread Tools Search this Thread
# 22  
Old 07-16-2013
Excelent summary of hotkeys.
Thanks.
# 23  
Old 08-09-2014
tabstop width

How to change Tab width in vim?
Say I have a file, columns are separated with single space (or maybe tab). I want to change space to tab (or different Tab width) so that the columns are aligned and nicely padded.
Code:
bob 100 90 30000 40 5
brian 40 30 20 10 10000
rob 10 2 30 40 50
mike 60 88 92 100 80

I tried setting different tabstop width to find the best one as :set ts=4; or :set ts=8, or :set ts=10, but tab width did not change at all in vim. What did I miss? Thanks!
# 24  
Old 08-09-2014
Quote:
Originally Posted by yifangt
How to change Tab width in vim?
Say I have a file, columns are separated with single space (or maybe tab). I want to change space to tab (or different Tab width) so that the columns are aligned and nicely padded.
Code:
bob 100 90 30000 40 5
brian 40 30 20 10 10000
rob 10 2 30 40 50
mike 60 88 92 100 80

I tried setting different tabstop width to find the best one as :set ts=4; or :set ts=8, or :set ts=10, but tab width did not change at all in vim. What did I miss? Thanks!
Code:
:set tabstop=number
     and
:set ts=number

will display lines being processed with tab stops set every number columns. It will not convert spaces to tabs. It will not replace sequences of spaces and tabs to make words on various lines magically align as columns in a table.
# 25  
Old 08-09-2014
Thanks Don!
Ah ha! Yes, after I did :%s/\ /\t/g then :set ts=6. It worked!
Does that mean I have to convert all the spaces with Tab first?
Thanks!
# 26  
Old 08-09-2014
Quote:
Originally Posted by yifangt
Thanks Don!
Ah ha! Yes, after I did :%s/\ /\t/g then :set ts=6. It worked!
Does that mean I have to convert all the spaces with Tab first?
Thanks!
The vim or vi utility will display each <tab> found in the input as the number of <space>s needed to reach a tab stop. It doesn't matter whether the <tab>s are put in place before or after you use :set to set the tab stops.
# 27  
Old 10-25-2016
In the post #1 of this thread, it is mentionned :

Code:
dd : Deletes three lines from current cursor position downwards.(also :d)

Shouldn't it be dd : Deletes the current line instead ???

I would also add :
cw : change 1 word begining from current cursor position
ncw : change n word begining from current cursor position
cW: change word treating only whitespace (or line ends) as word delimiters
C : Change the whole line from the current cursor position
D : Delete the current line from current cursor position (leaving in command mode contrary to the C command which do the same but switch to insert mode).
R : Replace (kind of overwrite, this command switch to insert mode)
My 2 cents.

Last edited by ctsgnb; 02-13-2017 at 06:01 AM.. Reason: Error in cW description (Thx bakunin for notice!)
# 28  
Old 11-28-2016
Thanks!

Excellent post
Login to Reply

« Previous Thread | Next Thread »
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
Basic VI tricks cokedude UNIX for Advanced & Expert Users 3 08-05-2011 04:11 PM
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
need couple of ksh tricks please JamesByars Shell Programming and Scripting 4 02-23-2008 02:07 PM
Set prompt, problems and tricks HybridLogic UNIX for Dummies Questions & Answers 6 09-26-2007 08:05 PM
tar tricks neked UNIX for Advanced & Expert Users 2 08-14-2006 03:14 PM


All times are GMT -4. The time now is 05:41 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password