Wed, 2009-01-21
You can open several files in tabs from the command line with vim, just type:
vim -p file1 file2 file3
And each file specified on the command line will be opened in a new tab.
To open a file in a new tab inside vim use :tabe file
To close a tab do :tabc
You can quickly switch between tabs typing gt or gT in normal mode. To switch to a particular tab prepend the tab number to gt, i.e. type #gt, where #gt is the tab number.
Leave a Comment » |
vim | Tagged: tabs, vim |
Permalink
Posted by davitenio
Sat, 2009-01-17
Vim has a so called “very magic” mode for regexes which allows you to use parenthesis, brackets, the alternative separator (i.e. ‘|’), pluses, etc. with their special meaning but without the need to escape those characters.
(see :help /\v)
Example:
Let’s say you have the following in your buffer:
12345aaa678
12345bbb678
12345aac678
If you execute
:%s/\d\{5\}\(\D\+\)\d\{3\}/\1/
you will get
aaa
bbb
aac
but it required a lot of backslash escaping in the regex. You can avoid the need to escape parenthesis, curly braces, pluses, etc. using vim’s “very magic” mode for regexes. The following would do exactly the same as the previous substitution command but with fewer escaping required:
:%s/\v\d{5}(\D+)\d{3}/\1/
Leave a Comment » |
vim | Tagged: regex, very magic mode, vim |
Permalink
Posted by davitenio
Tue, 2009-01-06
Just like <TAB> expands a filename given a prefix you can also expand a file name given the middle part of a file name.
Example:
$ ls
abc1def abc2def abc3def abc4def abc5def
$ ls *2*<ESC>g
Which will expand to:
$ ls abc2def
via a stackoverflow question
Leave a Comment » |
Uncategorized | Tagged: bash, glob |
Permalink
Posted by davitenio