vim file1 file2

open two files in vim


-3
By: bossNova
2012-09-06 21:48:12

These Might Interest You

  • lists the files found by find, waits for user input then uses xdg-open to open the selected file with the appropriate program. usage: findopen path expression [command] With the third optional input you can specify a command to use other than xdg-open, for example you could echo the filename to stdout then pipe it to another command. To get it to work for files with spaces it gets a bit messier... findopen() { files=( $(find "$1" -iname "$2" | tr ' ' '@') ); select file in "${files[@]//@/ }"; do ${3:-xdg-open} "$file"; break; done } You can replace the @ with any character that probably wont be in a file name.


    -1
    findopen() { local PS3="select file: "; select file in $(find "$1" -iname "$2"); do ${3:-xdg-open} $file; break; done }
    quigybo · 2010-02-28 02:28:59 0
  • Reduce the number of keystrokes it takes to open a file in vim. First of all, you just need to type "v", which is less than half the number of characters (!), and second-of-all, you only need to enter a substring of the file you want to open. For example, if you want to open the file, homework.txt, then type "v hom" to open it. Good tip is to use the lowest unique substring, otherwise you'll open multiple files in different buffers (which is sometimes desirable). Use Ctrl-^ to switch between buffers.


    0
    function v { if [ -z $1 ]; then vim; else vim *$1*; fi }
    kFiddle · 2009-04-11 23:06:43 2
  • A potential source of a full filesystem are large files left open but have been deleted. On Linux, a file may be deleted (removed/unlinked) while a process has it open. When this happens, the file is essentially invisible to other processes, but it still takes on physical space on the drive. Tools like du will not see it.


    0
    sudo lsof -nP | awk '/deleted/ { sum+=$8 } END { print sum }'
    jeffskinnerbox · 2015-09-19 00:45:23 3
  • when working under a cli sometime you need to list the files with ls but u can open gnome file browser with the command 'gnome-open .' under current directory


    -1
    gnome-open .
    pahnin · 2010-10-01 13:16:00 6
  • I often use "vim -p" to open in tabs rather than buffers.


    4
    vim $(grep test *)
    goatboy · 2009-07-15 10:15:04 1
  • Catches .swp, .swo, .swn, etc. If you have access to lsof, it'll give you more compressed output and show you the associated terminals (e.g., pts/5, which you could then use 'w' to figure out where it's originating from): lsof | grep '\.sw.$' If you have swp files turned off, you can do something like: ps x | grep '[g,v]im', but it won't tell you about files open in buffers, via :e [file]. Show Sample Output


    3
    vim -r 2>&1 | grep '\.sw.' -A 5 | grep 'still running' -B 5
    rkulla · 2010-04-17 19:43:35 1

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: