Read only for open directories in vim - macos

Then I open vim from terminal and open an directory like vim ., my starts in Read Only Mode.
I cant figure out why this happen and how I can change it.
If I start MacVim everything is fine. But then I start vim from the terminal and open a directory this screen comes. I can navigate one dir up and back again, and I have write access.
EDIT
I installed all my vim settings on Ubuntu 15.04. Now I can use
Does anybody know how to change this behaviour of vim?
Now I can use netw with the command vim . like I always used.
As you can see, there is no RO (read only) mark. How can
I have this in Mac on iTerm too?

What you see is exactly what you are supposed to see when doing $ vim .: the built-in netrw plugin displays a listing of the current directory that you can use to navigate your project.
If you don't want that listing, don't ask for it:
$ vim
or:
$ vim file

ctrl-p is not mapped by netrw; on my system, its set up by the yankring plugin. If vim is doing something other than going up one line, then you have a plugin involved. Try using :map to see what its mapped to; then do a search for that in your plugins directory.
The netrw way of opening a file in the same window is to use the <enter> key, although the g:netrw_browse_split variable may be used to change that default behavior.
Netrw opens in read-only mode, and that's not going to change. The file being opened should not be in read-only mode, however, if that's what you meant. If you're having a problem of that sort, please update your netrw; the most up-to-date version is at http://www.drchip.org/astronaut/vim/index.html#NETRW .

After I installed macvim 7.4 Every thing works!

Related

Opening a project directory in PhpStorm from the Terminal

I want to open a project directory in PhpStorm using pstorm .
I am aware that there are many threads that have discussed this issue, but I have not been able to completely solve my problem with the solutions from those threads.
Using the IntelliJ Toolbox, I click the gear icon (top right) and I enable the Generate Shell Scripts option. I set the Shell script location to /usr/local/bin (which is in my PATH). The Shell Script Name is specified as pstorm.
The first issue is that the script isn't generated in /usr/local/bin. Presumably since the Toolbox doesn't have write privileges at that location. I then set it somewhere where it has write privileges - something like /home/username/.local/share/JetBrains/Toolbox/bin. The script is successfully generated there under pstorm:
# Generated by JetBrains Toolbox 1.20.7940 at 2021-03-24T16:55:42.325644
"/home/username/.local/share/JetBrains/Toolbox/apps/PhpStorm/ch-0/203.7148.74/bin/phpstorm.sh" "$#"
I then copy that file to /usr/local/bin: sudo cp pstorm /usr/local/bin
I then open a terminal and navigate to my desired directory, opening said directory in PhpStorm with pstorm .
PhpStorm then opens the directory. However, PhpStorm is then 'locked' as a child to the (parent) terminal instance and closing the terminal also closes PhpStorm. A more complete explanation relating to this behaviour is given here
I would really prefer that PhpStorm not be dependend on a terminal instance, much like when I run code . for VSCode.
Any ideas why it is doing this and how to 'solve' this behaviour?

I seem to have two different Vim environments. What is causing this?

I am trying to set up a development environment on Windows 10. So far I've installed Vim and Cmder (the full version with Git for Windows).
Playing around, I noticed some strange behavior which I don't understand, but I feel like it is important that I understand.
Case A
I open PowerShell
Locate the folder that contains vim.exe
Run .\vim.exe
Vim pops up and displays the default screen (VIM - Vi IMproved, version 8.1.1, etc.)
In Normal Mode I type :version to check the version number and to see where my _vimrc file is located
Vim gives me the expected output
Case B
I open Cmder and open a new PowerShell tab (I am assuming that that gives me access to the PowerShell instead of the default cmd.exe, but please correct me if I am wrong.)
NOW THIS IS WHERE IT GETS INTERESTING
If I repeat steps 2-6 exactly as in Case A, I get exactly the same result.
BUT:
If instead of locating the folder that stores vim.exe I just type in vim and hit Enter it opens Vim once again, but this time it has a tab on the bottom that says "unix". See attached images.
Out of curiosity, in Normal Mode I type :version, just like in Case A, but this time I am getting a different date in the version section, a different selection of options, and a different Unix-like path to the vimrc file which in now .vimrc instead of _vimrc.
What gives? My guess is that Git for Windows that came with Cmder is simulating a Unix environment and accessing a different Vim version that was compiled for Unix?
If this is true, then could you help me make sense of this Windows/Unix environment duality? Do I now have two HOME folders, two copies of the vimrc file, and two copies of who knows what else? What is simulating this Unix environment - Cmder?
Thanks!
I don't have experience with Cmder, but I use Git for Windows a lot.
Git for Windows comes with some Unix utilities and uses Cygwin which is Unix emulator for running those. Vim is among them as default text editor for commit messages, etc. So it might be it.
I tried to reproduce this on my machine. but I cannot reproduce what you are seeing. Nonetheless I found the vimrc file for the Vim you are probably using in the second case.
It is in <Cmder-dir>\vendor\git-for-windows\etc\vimrc.
You have two different versions of Vim installed, and depending on the environment you start it from, one or the other gets selected. Git (as a tool that initially was developed on and for Linux) typically brings with it a set of Windows-ports.
You can check what Vim binary is used (respectively) from within Vim via
:echo v:progpath
Whether you live with this duplication or try to consistently use one Vim instance is up to you. It looks like the Vim that accompanies Git has more Unix-centric settings; it might be good to keep that to avoid interoperability issues.
You definitely don't need to clone your whole Vim configuration - as long as you stick to Unix-style (LF) line endings, it can be understood by any Vim. By setting the HOME environment variable (but that may affect other programs!), you can make Vim use the same location. Else, you could give one Vim config location a small .vimrc that just corrects 'runtimepath', and then :sources the "real" vimrc from the other location.

Installation of MacVim to use gvim

Previously I had gVim running and working; however, my hard drive crashed so everythin'g got erased. Anyways, I am trying to run gVim to open files "-bash: gVim: command not found. I installed X11 and MacVim and did everything that i did before but it just wont open my file. When i open my file with vim it works, but i would prefer gVim.
Any suggestions on how to get givm to work??
I'm not sure you know what you are doing.
MacVim has nothing to do with X11 at all so… are you trying to run GVim — the GTK front end of Vim — under X11 (to mimic a Linux desktop, maybe) or do you simply want to run some GUI Vim (GVim or MacVim, whatever).
If you really want GVim, you can install it (and its dependencies) from source but, judging by your question I don't think you should take that path.
If you only want a GUI Vim, the MacVim download comes with a mvim script that you can put anywhere in your $PATH. $ mvim filename will work just like $ gvim filename on Linux.
You can even rename that script to gvim if you absolutely need a gvim command.
You can install MacVim either from this site:
https://code.google.com/p/macvim/
or for example from the macports project, with port install MacVim (you must install first macports (see www.macports.org)
with macvim you will get the mvim terminal command, what is an small shell script.
TL;DR: gvim is aliased from the MacVim application's bin folder and you can add that bin directory to your $PATH variable to enable access to gvim from the terminal.
I recently downloaded the latest MacVim.dmg file from https://github.com/macvim-dev/macvim/releases, opened it, in the window that pops up, dragged the MacVim icon to the Applications icon, then closed that window and ejected the MacVim.dmg installer from the finder.
From a finder window I navigated to the /Applications folder, I right-clicked on MacVim.app and selected "Show Package Contents". Then I opened Contents/bin and there found a set of symlinks from mvim and gvim to vim.
I opened a terminal, and changed directory to the home directory by typing cd ~ . From the home directory, I typed ls -al to list all files even the hidden ones which start with a dot, and verify there was a .bash_profile file. (If you don't have this file, see if you have any other other profile files, or search the web to determine which to use or add, so that you can set the following additions to your $PATH variable and have them persist after you log out and back in.)
From the home directory, I used my favorite editor to edit the .bash_profile file, and added the following line to add MacVim's bin file to the $PATH variable:
export PATH=$PATH:/Applications/MacVim.app/Contents/bin
I saved and exited the .bash_profile file, then loaded my change with source .bash_profile. Now when I type in the terminal which gvim it lists that location, and I can run gvim from the terminal to open a file.
I’m a hard-core gvim user (i.e., I prefer gvim to vi, vim, mvim, and other text editors that are available on Mac). I’ve searched online for “How to install gvim on Mac?”, and have found many answers. The one answer that works best for me is as follows. Assuming you have brew available, on a terminal, type:
brew install macvim
You may be asked to fix some errors. Just follow the onscreen instructions, which may include running commands: brew unlink vim, brew unlink macvim, etc.
Once your macvim has been installed, type the following command:
brew link macvim
If this is successful, then gvim should have been installed, and you can verify this by typing:
which gvim
You should see:
/usr/local/bin/gvim
as the screen output.

Copy and paste in vim via keyboard between different mac terminals?

Can anyone help me with this:
I'm trying to figure out how to copy and paste text between 2 different instances of vim on different terminals (using iterm2 or mac terminal). I can do it using the mouse if I do ":set mouse=a" but I'd like to be able to do it using the keyboard.
I've googled around and it says you can use the "* or "+ registers to copy/paste to/from the system clipboard, but when I type * or + in vim, the mac makes one of those sounds it makes when you can't do something. I've also done ":set clipboard=unnamed" but that hasn't worked either.
I'm using Mac OSX 10.7 (Lion) and iTerm2 or Mac terminal.
Thanks for the help
Could you add the output of :version?
I can yank with yy or y in one Vim instance running in Terminal.app window A and put with p or P in another Vim instance running in Terminal.app window B with this line in my ~/.vimrc:
set clipboard+=unnamed
without using specific clipboard registers (* or +).
And why do you have two Vim instances running in different terminals? SSH/local? If one is in an SSH session yanking/putting won't work because the two machines (local/remote) don't share the same clipboard(s).
EDIT
I suspected that Vim wasn't compiled with the right flag(s). Apparently that's the case.
Since you are using Mac OS X's default Vim my opinion is that you shouldn't need to re-compile it or even compile anything as it often leads to more problem's than it's worth.
Instead, download the latest MacVim build and use the (CLI) Vim executable within MacVim's bundle: it has all the same functionalities as MacVim (within the constraints of the CLI, of course).
Add this line to your ~/.bashrc or ~/.profile or wherever you are used to put aliases and custom bash functions:
alias vim='/path/to/MacVim.app/Contents/MacOS/Vim'
If you want to copy an entire file into your target file.
Open your target file in vim.
Put your cursor where you want it and type the following:
:r /path_to_file/file.ext
This will copy an entire file to where your cursor is...

Delete gnome terminal configuration

I made a mistake in my gnome terminal configuration. I entered a command to start with in the preferences, but that command fails, and now all I get is a window that opens and closes right away, and I basically can't use gnome terminal anymore :-( Is there any way I can remove the configuration file and restart fresh??
Thanks!
Open the XTerm (Standard terminal for linux) and enter this command
gnome-terminal -e bash
It opens the gnome-terminal. Open profile preferences and configure your terminal to "Hold the terminal open".
Editing preferences
$HOME/.gconfd/saved_state
the above file might be of interest depending on exactly what configuration you changed. Of course, it holds configuration from other programs as well.
If you are on the newer gnome terminal that uses dconf, it's a little trickier, but still doable:
Profiles are stored with a UUID, you need to find the UUID of the profile to remove:
dconf dump /org/gnome/terminal/ | less
Search for a visible-name='...' entry matching the profile you want to remove. Look above that for the section header like [legacy/profiles:/:...]. The full name of the item you want to delete is thus /org/gnome/terminal/legacy/profiles:/:.... Delete it thus:
dconf reset -f /org/gnome/terminal/legacy/profiles:/:...
Side note: This Q&A probably should be moved to unix.stackexchange.com.

Resources