VectorLinux

Please login or register.

Login with username, password and session length
Advanced search  

News:

Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

Author Topic: opening files in Vim  (Read 3084 times)

brock

  • Member
  • *
  • Posts: 26
opening files in Vim
« on: March 22, 2008, 10: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: [Select]
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
Re: opening files in Vim
« Reply #1 on: March 22, 2008, 11: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: 2305
Re: opening files in Vim
« Reply #2 on: March 23, 2008, 07: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: [Select]
"   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
Re: opening files in Vim
« Reply #3 on: March 23, 2008, 04: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
Re: opening files in Vim
« Reply #4 on: March 23, 2008, 04:27:47 pm »

if you want to open a file with vim from the console, you can
Code: [Select]
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: [Select]
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

Triarius Fidelis

  • Vecteloper
  • Vectorian
  • ****
  • Posts: 2399
  • Domine, exaudi vocem meam
    • my website
Re: opening files in Vim
« Reply #5 on: March 23, 2008, 07: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