Sponsored Content
Top Forums Shell Programming and Scripting Vim : Match all bracket { and fold them (zf%) Post 302974264 by Purgator on Friday 27th of May 2016 05:07:38 AM
Old 05-27-2016
Hello,

i found a way to do that easy by using a macro.

Type 'q' to begin recording the macro, then select a register between a-z. Now type the macro '/{' + 'zf%'. Press q at the end to finish recording.
Now you can do something like '10@q' to play 10 times this macro. I still need to improve it to make it begin at the top of the file and end at the bottom, but it's already a quick easy way to deserve the purpose.

Summary :
Create macro
Code:
qa/{<Enter>zf%q

Execute macro
Code:
10@a

Just be careful to not doing zf multiple times on the same {

Enjoy

EDIT : I'm here again, just call :set nowrapscan to configure search not going back to the beggining of the file. Then you can simply do 1000@a end all functions gonna be collapse 1 time.

Last edited by Purgator; 05-27-2016 at 06:20 AM.. Reason: improving answer
This User Gave Thanks to Purgator For This Post:
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Best practice for bracket comparisons?

So, I have no formal higher education in programming at all and am self taught. I am now wondering what would be considered best practices? Like should I hard code a variable, then compare it to what I want to know or achieve, or should I just put the commands with in the brackets? Example, a... (5 Replies)
Discussion started by: tlarkin
5 Replies

2. Solaris

Very Importan - Vim Settings - Error while opening a File using vim

I downloaded vim.7.2 and compiled the vim source . Added the vim binary path to PATH (Because iam not the root of the box) when i load the file using vim it throws me an error Error detected while processing /home2/e3003091/.vimrc: line 2: E185: Cannot find color scheme darkblue line... (0 Replies)
Discussion started by: girija
0 Replies

3. Shell Programming and Scripting

Split a string with bracket

Hi, Am trying to split a string with bracket in ksh but it is not splitting it correctly. split("Hello, Name(1), Name(2)", main,","); How do i split correctly? (3 Replies)
Discussion started by: nightrider
3 Replies

4. Shell Programming and Scripting

Double bracket giving error

here is a small script I wrote: #! /bin/bash if ] then echo "argument is null" fi It is giving error: test.sh: any idea, why is it so? (2 Replies)
Discussion started by: vina201unx2011
2 Replies

5. Shell Programming and Scripting

ksh, difference between double bracket and single bracket

Can somebody tell me the difference between double brackets and single brackets, when doing a test. I have always been acustomed to using single brackets and have not encountered any issues to date. Why would somebody use double brackets. Ie if ] vs if Thanks to... (2 Replies)
Discussion started by: BeefStu
2 Replies

6. UNIX for Dummies Questions & Answers

Vim Match problem

Goodmorning, I've some problem in using regular expression in a VIM syntax configuration file. I've need to match a string as <<< some to match >>> so that it matches only some to match . With standard regular expression i know that for this goal works fine the regex: (?<=<{3}).*(?=>{3}) ... (4 Replies)
Discussion started by: keltron
4 Replies

7. Shell Programming and Scripting

Remove bracket part

Hi I have to remove in a file in first column whatever is written in brackets with brackets so one file hgfd 123 gfhdj 483 jdgfdg 34738 the output shuld be hgfd 123 gfhdj 483 jdgfdg 34738 (9 Replies)
Discussion started by: manigrover
9 Replies

8. Shell Programming and Scripting

variable inside if bracket

Is this possible? The below code not working for me. dir=mydir if ; then echo "found /home/$mydir " else echo "Not found /home/$mydir" fi ---------- Post updated at 05:28 AM ---------- Previous update was at 05:25 AM ---------- Its working for me now (1 Reply)
Discussion started by: anil510
1 Replies
VIMDIFF(1)                                                    General Commands Manual                                                   VIMDIFF(1)

NAME
vimdiff - edit two, three or four versions of a file with Vim and show differences SYNOPSIS
vimdiff [options] file1 file2 [file3 [file4]] gvimdiff DESCRIPTION
Vimdiff starts Vim on two (or three or four) files. Each file gets its own window. The differences between the files are highlighted. This is a nice way to inspect changes and to move changes from one version to another version of the same file. See vim(1) for details about Vim itself. When started as gvimdiff the GUI will be started, if available. In each window the 'diff' option will be set, which causes the differences to be highlighted. The 'wrap' and 'scrollbind' options are set to make the text look good. The 'foldmethod' option is set to "diff", which puts ranges of lines without changes in a fold. 'foldcolumn' is set to two to make it easy to spot the folds and open or close them. OPTIONS
Vertical splits are used to align the lines, as if the "-O" argument was used. To use horizontal splits instead, use the "-o" argument. For all other arguments see vim(1). SEE ALSO
vim(1) AUTHOR
Most of Vim was made by Bram Moolenaar, with a lot of help from others. See ":help credits" in Vim. 2001 March 30 VIMDIFF(1)
All times are GMT -4. The time now is 02:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy