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 07:01 AM.. Reason: Error in cW description (Thx bakunin for notice!)
# 28  
Old 11-28-2016
Thanks!

Excellent post
Login to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Any tricks on excluding a set of strings from a file? newbie_01 UNIX for Dummies Questions & Answers 3 05-22-2013 03:22 AM
Basic VI tricks cokedude UNIX for Advanced & Expert Users 3 08-05-2011 05:11 PM
tips xerox UNIX for Dummies Questions & Answers 1 02-24-2011 09:01 AM
Very Importan - Vim Settings - Error while opening a File using vim girija Solaris 0 08-13-2010 09:37 AM
Sed Tricks siba.s.nayak UNIX for Dummies Questions & Answers 3 10-20-2009 04:01 AM
Solaris tips and tricks solaris_user Post Here to Contact Site Administrators and Moderators 1 09-24-2009 02:02 PM
need couple of ksh tricks please JamesByars Shell Programming and Scripting 4 02-23-2008 03:07 PM
Set prompt, problems and tricks HybridLogic UNIX for Dummies Questions & Answers 6 09-26-2007 09:05 PM
tar tricks neked UNIX for Advanced & Expert Users 2 08-14-2006 04:14 PM
All times are GMT -4. The time now is 05:37 PM.

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