MATLAB Examples

Example nav

Contents

Basic use

Example 1: addcd, show, reset

%Reset the previous links and remove the other favorites groups
nav reset
nav remallgrps

All the groups but the current one are now removed

%Add the current directory and its parent
nav addcd
cd ..
pause(0.5);
nav addcd

%Show the links
nav

thisParentFolder    thisFolder

Add the files in the editor

Example 2: add all the files currently open in the editor

%Reset the previous links and remove the other favorites groups
nav reset
nav remallgrps

All the groups but the current one are now removed

%Add the paths to sum.m and to diff.m
open sum.m
open diff.m
nav addcf

%Show the links
nav

diff.m    sum.m

Remove a link

Example 3: remove a link using remaf

%Reset the previous links and remove the other favorites groups
nav reset
nav remallgrps

All the groups but the current one are now removed

%Add the paths to sum.m and to diff.m
open sum.m
open diff.m
nav addcf

%I don't want diff.m anymore. Since it is the active file, just type
nav remaf

%Show the links
nav

sum.m

Groups

Example 4: working with groups

%Reset the all the links in all groups
nav resetall

%Remove all the other favorites groups
nav remallgrps

All the groups but the current one are now removed

%Show current group name
nav grp

Current group: default

%Create new group, and make it the current one
nav grp newPrj1

%This group contains initially no link. Add some link
nav addcf
nav addcd

%nav will show only the current group links
nav

thisFolder    diff.m    sum.m

%Create another group, and make it the current one
nav grp newPrj2

%Show all the group names. Clicking a link will change the current group
nav grps

Current group: newPrj2


Group: default    Group: newPrj1

%Suppose that some links in newPrj1 are now corrupted. You can remove
%the corrupted links without changing the current group
nav rembrk newPrj1

%Suppose that all the links in newPrj1 are now useless. You can reset
%them without changing the current group
nav reset newPrj1

%Suppose now that newPrj1 is no more useful. You can entirely remove
%the group along with its links
nav remgrp newPrj1

The group newPrj1 has been deleted

Static bookmarks

%Example 5: work with static bookmarks
%Reset the previous links and remove the other favorites groups
nav reset
nav remallgrps

All the groups but the current one are now removed

%In nav.m there are 2 examples of static bookmarks.
%Their ids are 'internalFuncs' and 'addOrRemove' respectively.
%Add the first static bookmark to the navigation links
nav add nav.m/internalFuncs  %In Mac/Unix, replace '/' with '\'

%Show the links. Clicking internalFuncs will let you jump in a specific
%location of nav.m
nav

internalFuncs

%Remove the last inserted link
nav rem nav.m/internalFuncs

%Add ALL the internal bookmarks of nav.m and display them
nav add nav.m/*

addOrRemove    internalFuncs

Add files matching a pattern

Example 6: add all the files that match a regular expression

%Reset the previous links and remove the other favorites groups
nav reset
nav remallgrps

All the groups but the current one are now removed

%Add all the m files whose filename ends with Example
nav addregexp .*Example\.m$

%Remove all the m files whose filename starts with n
nav remregexp ^n

%Show the links
nav

cdafExample.m       aofExample.m    owdeExample.m
genOpenExample.m    odExample.m     upExample.m

Remove broken links

Example 7: remove all the broken links (links pointing to files or folders that do not exist anymore)

%Reset the previous links and remove the other favorites groups
nav reset
nav remallgrps

All the groups but the current one are now removed

%Create a file in the current directory
copyfile(which('sum.m'),fullfile(cd, 'demoSum.m'))

%Add the created file
nav add demoSum.m

%Add the current directory
nav addcd

%Delete the file. Now the link pointing to demoSum is broken
delete(fullfile(cd, 'demoSum.m'));

%Show the links
nav
thisFolder    demoSum.m (broken)

%Remove the broken links
nav rembrk

%Show the links
nav

thisFolder