I'm having an issue with vim while I'm trying to remotely edit a sqlrpgle file in AS/400. I'm using the next command to open the file in vim:
:e ftp://myusername#mydomain/mylibrary/mymember.myfile
The file opens up but is filled with # characters instead of source code. Am I calling it the wrong way?
I tried writing the command this way but it failed:
:e ftp://myusername#mydomain/mylibrary/mymember.myfile.sqlrpgle
The "#" characters (0x40) are EBCDIC spaces.
Enable ASCII transfer mode with the following netrw option:
:let g:netrw_ftpmode="ascii"
Edit files using the following format:
:e ftp://user#host/library/file.member
Related
Hi I'm a new user to vim text editor (love it) and would like to save my preferences in VIM ie font and size and background colour, ive searched and the only things i can find say modify the rc file however they do not specify how except to advise on customisations such as line spacing. Please could someone advise?
On a Linux machine, you can start making a .vimrc file in your home folder by running the following in the terminal:
vim ~/.vimrc
This is the "rc" file that they are talking about.
Regarding the formatting of this file, you can put every setting on a separate line:
" This line is a comment, the following 2 lines are settings:
colorscheme desert
set history=500
While still in vim, save with :wq.
The next time you start vim, it will use the settings that you just specified in your ~/.vimrc.
Here is the $ vimtutor section dedicated to that very subject:
Lesson 7.2: CREATE A STARTUP SCRIPT
** Enable Vim features **
Vim has many more features than Vi, but most of them are disabled by
default. To start using more features you have to create a "vimrc" file.
1. Start editing the "vimrc" file. This depends on your system:
:e ~/.vimrc for Unix
:e ~/_vimrc for Windows
2. Now read the example "vimrc" file contents:
:r $VIMRUNTIME/vimrc_example.vim
3. Write the file with:
:w
The next time you start Vim it will use syntax highlighting.
You can add all your preferred settings to this "vimrc" file.
For more information type :help vimrc-intro
How can I setup file names completion while I am opening the file.
For example:
:o ~/.vimr<tab>
I want to get .vimrc file, but get ^I char if I press the Tab-key.
I use MacVim.
How about using :edit instead of :o? Apparently, :o doesn't take a file path as an argument.
I use Gvim to write code. And use vifm to make file management ( copy, move files, extract tar's ). Sometimes, when navigating in vifm i need to open some file to edit him. Using :e it opened vim in same window. Is there any way to open file to edit in already opened gvim program?
You can use Vim's client-server feature to send the :edit to the existing GVIM instance. In the terminal Vim / vifm, execute:
:!gvim --remote path/to/file
See :help remote.txt for details. You can also open the file in a new tab page with --remote-tab etc.
Partial solution/workaround (I'm using a mac fwiw):
In vfimrc, define
" yank current file path into the clipboard
nnoremap Cf :!echo -n %c:p | pbcopy %i<cr>
To copy filename and dir into system clipboard
Then in vifm, cursor over file and type
Cf
:!gvim "
<cmd-v>
to paste clipboard,
and finish expression with...
"
<enter>
and now that file should open in gvim. It worked for me
I find myself in the position where I want to create a new file in the same directory as the one that the open file is in. How do I create a new file in the directory of the open file in vim? Also, is there a a place where I can learn these things on my own? Googling didn't help.
From within Vim, new files are created like existing files are edited, via commands like :edit filename or :split filename. To persist them to disk, you need to (optionally type in contents and) persist them via :write.
Like a command prompt, Vim has a notion of current directory (:pwd lists it). All file paths are relative to it. You don't need to duplicate the path to your current file, there are some nice shortcuts for them: % refers to the current file, :h is a modifier for its directory, minus the file name (cp. :help filename-modifiers). So,
:e %:h/filename
:w
will create a new file named filename in the same directory as the currently open file, and write it.
Alternatively, some people like Vim to always change to the current file's directory. This can be configured by placing
:set autochdir
into your ~/.vimrc file (which is read on Vim startup). Then, above becomes simply
:e filename
:w
Finally, Vim has a great built-in :help. Learn to navigate and search it!
you should have a try with "nerdtree" plugin.
In the nerdtree window, you typed key m, and file operation choices will display to you
If you want to create a new file and also show it in the window next to your current file, you can try this:
:vsp newfile
The vsp stands for vertical split, and it splits the screen in half, one showing your current file, the other showing your new file (also works with just sp, which is a horizontal split).
Per #MartinLyne's comment above, this will create the file in the directory of the file in which you opened vim. To adjust for this, you can change the current working directory as follows:
:cd %:p:h
This command changes the current working directory to the directory of the active file, meaning that running the vsp command (or any of the commands above) will create the file in that directory.
I usually use:
:tabnew my-file
Then add some content and:
:w
It will create new tab with new file.
(I use Vim 8)
When you have opened vim in non existent location like
$ vim /etc/<some_folder/<next_folder>/file.cfg
then to create a new directory while being inside vim, just run in normal mode
:! mkdir -p /etc/<some_folder/<next_folder>
next save your doc as usual :w :x ZZ (whatever you like)
that's it
I'm quite late to the party, but another option is to open NERDtree with :E or :Explore (or its splitting alternatives :Vexplore/:Sexplore == :Vex/:Sex).
In NerdTree you can create a new file with %, and type the name. It will automatically open the file, and create it after you :w/save it.
This is for Gvim!
Enter this to see the current directory.
:cd
then change it with
:cd desktop/somefolder
then save or make new file there
:enew asd.cpp
now again see the file
:cd
With NERDtree
ma <FILENAME>
ma <DIRECTORY NAME> + /
I've run into an odd problem in Vim. I would like to drag and drop a file from my desktop or file manager into Vim and edit it. Gvim handles this behavior correctly.
When I attempt to do the same thing in console Vim, the path to the file name is inserted instead. For example, if I drag and drop the file /home/myuser/foo.matic, it will apply the text string '/home/myuser/foo.matic' to the current buffer.
If I type :edit, then drag and drop the file name, Vim treats '/home/myuser/foo.matic' as a new directory.
I believe the problem here is the quotes before and after the file path. These appear to be inserted by both gnome-terminal and terminator. Is there a way to strip these quotes from the file name when dragging and dropping? Alternatively, is there a way for Vim to ignore the quotes?
You can’t make vim own :e command to do what you need, but you can define your own one. Most straightforward solution - make shell parse what was intended to be parsed by the shell - is listed below:
command -nargs=? -bang -bar E :execute "e<bang> ".fnameescape(system("echo -n ".<q-args>))
. This command accepts only :e[!] {file} variant, no +cmd and ++opts are allowed.