Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-23-2009, 08:29 PM   #1
Registered: Apr 2009
Posts: 42

Rep: Reputation: 15
Vim query

Message originally posted in wrong forum... oops

Anyhoo, I'm using snipMate for vim, I'd like to edit each of the ~/.vim/snippets/*.snippets files so that the tabs are replaced with 4 spaces (without changing the universal tabstops value), but I need to leave unchanged the first hard tab on any line which follows a line starting with 'snippet', as the snipMate.vim script uses it to recognise where to start.

For example:

# main()
snippet main
<--\t-->int main(int argc, const char *argv[])
<--\t--><--\t-->return 0;
should be changed to

# main()
snippet main
<--\t-->int main(int argc, const char *argv[])
        return 0;
(where <--\t--> is currently a tab, naturally).

Do you know how I can do this in vim with a replace command - or better yet, using sed so I can apply it to the whole directory full of .snippet files at once?

Old 09-23-2009, 09:47 PM   #2
Registered: Apr 2009
Posts: 42

Original Poster
Rep: Reputation: 15
Never mind, I figured it out: in snipMate.vim, after line 150 ('if snippet != '') i inserted:

let snippet = substitute(snippet, '\t', repeat(' ', &sts), 'g')

which seems to have done the trick. Easier than I thought it would be, too

Last edited by ColInvictus; 09-25-2009 at 08:50 PM. Reason: improvement to solution
Old 09-23-2009, 11:30 PM   #3
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Glad you got it solved - vim rocks. BTW, you can mark this thread 'solved' then. And if you accidentally post a thread in the wrong forum, you can ask a mod to move it vs. posting another. If you do post dupes, you can hit the 'report' button to inform a mod to close it. If you already did that, then never mind, but I did on the other thread in case you didn't.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Vim query ColInvictus Programming 1 09-23-2009 09:49 PM
Switching from vim to vim -g from inside vim iDragoon Linux - Software 4 05-15-2009 12:46 PM
Editor comparison: vim VS vim-lite, Cleaning vim Ruler2112 *BSD 4 04-13-2009 05:26 PM
LXer: Vim tips: Using Vim mappings and abbreviations LXer Syndicated Linux News 0 06-18-2006 02:54 PM
LXer: Cream for Vim - Making Vim more user friendly LXer Syndicated Linux News 0 06-18-2006 12:54 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:07 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration