VectorLinux
December 22, 2014, 05:53:28 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Visit our home page for VL info. To search the old message board go to http://vectorlinux.com/forum1. The first VL forum is temporarily offline until we can find a host for it. Thanks for your patience.
 
Now powered by KnowledgeDex.
   Home   Help Search Login Register  
Please support VectorLinux!
Pages: [1]
  Print  
Author Topic: opening files in Vim  (Read 2887 times)
brock
Member
*
Posts: 26


« on: March 22, 2008, 09:27:29 pm »

Now that I've got my new Vim icon set up, I've got a new problem.  I've been doing the Vimtutor and reading up on it and it says that to open an existing document with Vim, type

Code:
Vim 'nameofdocument'

But when I do that, type in a name of an existing document on my system, vim opens up blank, with the title on the bottom, like it just opened up a new file named "whateverInamedit".  So I was wondering, since the directions don't seem to work, do we have a different way of opening files with Vim with Vector?  I thought maybe we might have "VectorVim" or something?
Logged

ChemBook Laptop (it was free) 1.50 GHz 1 gig ram 1024x768 screen Ethernet-cable modem (working on wireless), Vector 5.9 Standard Gold, HD install, NO dual boot--windowsfree system!  prefer Xfce for now
toothandnail
Tester
Vectorian
****
Posts: 2527


« Reply #1 on: March 22, 2008, 10:23:47 pm »

Are you in the same directory as the document, or are you entering the full path to the document if you are not in its directory?

paul.
Logged
rbistolfi
Packager
Vectorian
****
Posts: 2291


« Reply #2 on: March 23, 2008, 06:41:12 am »

As kidd and Epic_Fail_Guy are not much around lately, the bad but enthusiastic discipuli will get in.
You can open a file with : o, (those smileys are not vim friendly, forget the space between : and o) but in my experience it will not let you do tab-completion. Instead, you can use the edit command, :e which will let you complete the path with <tab>.
Also, I took this one from the vim tips plugin and I put it in my .vimrc:

Code:
"   Edit another file in the same directory as the current file
"   uses expression to extract path from current file's path
"  (thanks Douglas Potts)
if has("unix")
    map ,e :e <C-R>=expand("%:p:h") . "/" <CR>
else
    map ,e :e <C-R>=expand("%:p:h") . "\" <CR>
endif

That will let you open a file from the last used path with ,e in normal mode.

HTH
Logged

"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!
brock
Member
*
Posts: 26


« Reply #3 on: March 23, 2008, 03:10:56 pm »

If I go into the directory with bash, and then 'vim name' it works.  Is that the only way to do this? 
Logged

ChemBook Laptop (it was free) 1.50 GHz 1 gig ram 1024x768 screen Ethernet-cable modem (working on wireless), Vector 5.9 Standard Gold, HD install, NO dual boot--windowsfree system!  prefer Xfce for now
kidd
Packager
Vectorian
****
Posts: 682


« Reply #4 on: March 23, 2008, 03:27:47 pm »

if you want to open a file with vim from the console, you can
Code:
vim file

if the file does not exist, vim will open it anyways, and create when you do the first :w

if you want to open a file not in the `pwd` you're in bash, you have to type the full path
Code:
vim /tmp/file.c

inside vim, :e is the command to open files, and it will start from the directory you opened vim.  If you opened it from the console, probably it'll be your $HOME dir.

type :pwd  to find out where vim will first look at.

inside vim, you can type absolute paths, like :e /tmp/file.c

Depending on your vim options (@compile time), you should be able to 'edit' a directory.   Then it'll list you all files there, and you can edit whatever is there.

more info in :help edit-a-file

:help  has tons of info. the first 'user manual' sections are really useful as well as first reference manual sections.

HTH

kidd
Logged

Triarius Fidelis
Vecteloper
Vectorian
****
Posts: 2399


Domine, exaudi vocem meam


WWW
« Reply #5 on: March 23, 2008, 06:20:20 pm »

I prefer to type ':split' in Ex mode and use tab completion to find the file. That feature should be enabled automatically if ':set compatible?' says 'nocompatible', id est Vim acts like Vim, not vi
Logged

"Leatherface, you BITCH! Ho Chi Minh, hah hah hah!"

Formerly known as "Epic Fail Guy" and "Döden" in recent months
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!