vim surround extension install problems - vim

I am trying to install the vim (7.4) surround extension on Arch Linux (downloaded and installed this week) within an Oracle VM on a Windows 7 host.
I am getting a variety of errors including E388 (Could not find definition) when on "Hello World" with my cursor inside the quotes I try:
:ds"
And E257 (cstag: tag not found) when on <div>Hello World</div> with my cursor inside the tags I try something like:
:cst<p>
I have downloaded the most recent version of vim surround from git
I have :set nocp
I have placed surround.vim in ~/.vim/plugin
I have restarted vim
I have regenerated the helptags, and :help surround does work.
I extracted the files as the user running vim, there is no permission error.
Running :scriptnames shows ~/.vim/plugin/surround in the list.
So as far as I can tell it is installed, just that it is not working. Any ideas?

Surround is almost certainly working correctly, you just don't know how to use it and/or don't understand the difference between "Ex" commands and normal mode commands.
:ds is the short form of :dsplit, see :help :dsplit.
:cst is the short form of :cstag, see :help :cstag.
They are "Ex" commands, but Surround's ds and cst are not "Ex" commands: they are normal mode commands.
Instead of doing:
:ds"
:cst<p>
do:
ds"
cst<p>
And… Read The Fantastic Manual: :help surround.

Related

How to issue Vim commands in command mode (`Enter` not working)

I installed neovim with pkg install neovim. I then downloaded the latest version of Nvim-R with curl -L "https://www.vim.org/scripts/download_script.php?src_id=26482" > NvimR.vmb. Finally, I opened the file with nvim NvimR.vmb.
Now I'm in the editor and I launch the command mode by pressing the : key on my keyboard. I then proceed to type packadd vimball into the command console. Finally I try to issue the packadd vimball command by hitting Enter on my keyboard and nothing happens. I look up in the editor panel and notice each time I hit Enter the cursor is just being moved around in the editor.
I don't want the cursor to move around in the editor. I want to issue my :packadd vimball command. How do I do this?
Everything I see in that gif is precisely what I would expect to see given what you typed.
You run :packadd vimballEnter—this does vim’s native packadd command (assuming nvim has that), and then returns you to the editing portion of the screen.
Subsequent Enter presses are equivalent to j—move down a line.
All of that said, I dont know of any packages named vimball, but I don’t really work with that format. Perhaps you’ve misunderstood a plugin’s usage or vimball usage? Ask about that stuff on vi.stackexchange.com: we probably have better vi/m experts there.

What is the "--servername" in "vim --servername VIM test.R"?

I just installed the vim-r-plugin on a Linux server and I found this issue (see below figure) prompted from the R console window (vimcom: Did you pass the --servername argument to Vim? ...) when I typed "\rf":
To solve the issue I followed the instructions here and was trying to find the "servername" and tested some commands such like:
But I have no idea what's the "--servername" I should use here. Any suggestions or answers? Thanks!
--servername is usually followed by some arbitrarily chosen name. This allows external processes like those used by your R plugin to interact with a running instance of Vim.
When the feature is available, GVim always starts as if you added --servername GVIMn where n is a number incremented for each new GUI window. You can see it on the right of the window title.
But you are using Vim so you'll need to do that explicitely:
$ vim --servername FOO

Why does my shell prompt disappear when I install vim 7.4?

I'm using CentOS 6. Since the CentOS repos have an older version of vim (7.2), I have compiled my own. However, I am having a weird issue. After running and exiting vim, I've found that my shell prompt has disappeared. Also, when I type, it does not appear in the terminal, nor does any output. What's weird is that it looks as though something is being outputted, since the cursor will move down the screen, but I can't see anything.
It must have something to do with compiling an X version, because it does not happen when I compile vim without X windows support (but I would like to have gvim, too). Here are the configuration options I supplied when compiling:
./configure --prefix=$OPT/Cellar/vim/7.4 --with-features=huge --enable-gui=auto --with-x --enable-xim
I also tried compiling without Xim. I've also tried explicitly setting --enable-gui=gtk2 (which is what gvim 7.2 from the CentOS repos uses).
I am using KDE4. The problem occurs both when running tcsh and bash. I have tried with $TERM set to both xterm and xterm-256color as well.
Additionally, running neither reset nor stty sane restores the shell to its proper behavior.
Any idea why my prompt disappears when running vim? As I missing a config flag or some other compilation issue?
I ultimately traced this down to an error in my ~/.vimrc file. I had some lines like this:
if has('gui_running')
# Gvim customization
endif
if has('gui_gtk2')
# GTK2-specific Gvim customization
endif
The second block was running every time vim loaded. Because it changed some window geometry, it ended up messing up bash; when I dropped back to bash, bash thought it only had ~53 columns to work with (and possibly some other things were messed up).
Solution: The second if block should be inside the first.

How do I use Vim with Rebar

Trying to get up and running Vim + Rebar.
Separately they work but not together. What I want to achieve is to run eunit without leaving the Vim.
I guess this is doable with following plugin https://github.com/mbbx6spp/vim-rebar . Unfortunately is very poorly documented.
How do I run my tests quickly, see the output, code and once again.
All your feedback will be appreciated.
I don't know how to integrate rebar into vim, but perhaps you could try tmux? This works for me. In one window I keep opened vim, another window i use as compilation/attach session to erlang node.
One quick way to get out of Vim is to suspend it with Ctrl+z, run your commands, and then foreground it again with fg afterwards. Works at least on bash in Os X and Ubuntu Linux.
You can also run command line commands with :! <command name> directly from Vim, e.g. :! ls.
Yet another way is to use screen, with one window running vim and another still on the command line.
The best solution I've found is to use a Makefile in my project. Since vim is capable of running shell commands, you can call make & have it use your makefile. Then map these shell commands to shortcuts of your choosing.
For example, my Makefile has the following:
test:
$(REBAR) skip_deps=true eunit
In my .vimrc:
command MakeErlangTest !make test
nmap <leader>r :MakeErlangTest<CR>

How do I set the UI language in vim?

I saw this on reddit, and it reminded me of one of my vim gripes: It shows the UI in German. I want English. But since my OS is set up in German (the standard at our office), I guess vim is actually trying to be helpful.
What magic incantations must I perform to get vim to switch the UI language? I have tried googling on various occasions, but can't seem to find an answer.
For reference, in Windows (7) I just deleted the directory C:\Program Files (x86)\Vim\vim72\lang. That made it fallback to en_US.
Try this in _vimrc. It works with my win7.
set langmenu=en_US
let $LANG = 'en_US'
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
As Ken noted, you want the :language command.
Note that putting this in your .vimrc or .gvimrc won’t help you with the menus in gvim, since their definition is loaded once at startup, very early on, and not re-read again later. So you really do need to set LC_ALL (or more specifically LC_MESSAGES) in your environment – or on non-Unixoid systems (eg. Windows), you can pass the --cmd switch (which executes the given command first thing, as opposed to the -c option):
gvim --cmd "lang en_US"
As I mentioned, you don’t need to use LC_ALL, which will forcibly switch all aspects of your computing environment. You can do more nuanced stuff. F.ex., my own locale settings look like this:
LANG=en_US.utf8
LC_CTYPE=de_DE.utf8
LC_COLLATE=C
This means I get a largely English system, but with German semantics for letters, except that the default sort order is ASCIIbetical (ie. sort by codepoint, not according to language conventions). You could use a different variation; see man 7 locale for more.
Putting this line of code at the top of my _vimrc file saved my day:
set langmenu=en_US.UTF-8
This worked for changing vim's menu language
set langmenu=en_US.UTF-8 [or just set langmenu=en for short]
But
language en
gave me an error sayng it couldn't set en as a language but this line did the job
:let $LANG = 'en'
The latter come from the Vim's docs. I added both lines at the beginning of the _vimrc file. I use a Windows 7 64 computer.
PS: this line changes both language and menus language
language messages en
In the .vimrc file (or _vimrc file if you are in windows)
Ubuntu 10.10 + VIM 7.2 IMproved. Code below changes language for console vim.
Add it at top of your vim.rc
if has('unix')
language messages C
else
language messages en
endif
Adding this to _vimrc works for me in windows 8:
set langmenu=en_US
let $LANG = 'en_US'
(note that _vimrc is in the same directory that contains my vim74 dir, thats the _vimrc file that vim reads at startup)
:help language
:language fr_FR.ISO_8859-1
These two lines at the begining of your .vimrc file will do the job:
let $LANG = 'en'
set langmenu=none
Start vim with a changed locale:
LC_ALL=en_GB.utf-8 vim
Or export that variable per default in your bashrc/profile.
Two Vim installations on Windows
Nothing from here around have helped me until I have realized that I have 2 Vim installed.
Git Bash via MinGW (Cygwin, mintty)
A separate installation in the Program Files on Windows
Next command will filter you all watched vimrc-files and their locations.
vim --version | grep vimrc
_vimrc (Windows & CMD)
.vimrc (Bash for Git)
vimrc (has different locations for both)
1: Vim on Windows & CMD
Only renaming (deletion) of the lang folder helped me.
You can find it here C:\Program Files (x86)\Vim\vim80\lang
I tried all config settings listed here around and it was useless.
2.1: Git Bash through MinGW, Cygwin, mintty
For Git Bash I added language messages en_US at the top of C:\Program Files\Git\etc\vimrc
Of course, if you prefer to delete the lang folder you can find it here
C:\Program Files\Git\usr\share\vim\vim80\lang
C:\Users\User_name_xxx\AppData\Local\Programs\Git\usr\share\vim\vim80\lang for a local user installation.
2.2: Tuning only Git's Bash (MinGW64, Cygwin, mintty)
At the end, for Bash on Windows I have chosen to skip manipulations with vimrc
I opened C:\Program Files\Git\etc\bash.bashrc
and added the following line
LANG='en_US'
or
LANG=C
Try to do not use en_US.UTF-8 because it forces some bash commands to produce weird chars. For example in find 'xxx_yyy_zzz_aaa.bbbddd' for a non-existing file.
I don't know why all of the above answers did not work for me. I kept getting errors about the locales not existing. Maybe it's a Windows thing. At any rate, my solution was to add this to my vimrc:
let $LANG = 'en'
Ah, I spoke too soon. The menus of gVim are still in Japanese, but the intro screen is in English.
Try adding this to your _vimrc:
let $LANG='en_US'
I simply disabled the Native Language Support when installing gvim
(thus making it a custom installation).
Tested successfully with gvim82.exe under Windows 7.
Had similar issue, but neither one of above solution worked:
https://superuser.com/questions/552504/vim-ui-language-issue/552523
I've resolved it by removing all vim packets and build vim from sources.
Hope it'll help someone.
If you're on Windows and don't want to be bothered issuing commands
To prevent the GUI from loading localization files
Just go to Program Files\Vim\vim80\lang and put an underscore as a prefix in front of all the files that look like they have something to do with your locale.
To prevent VIM itself from loading localization files
In the same folder as above, prefix with an underscore the folder named with your country code.
Note: Windows 10 will probably ask for Administrator privileges by raising a UAC warning.
By the way
This same technique can be applied to a lot of Unix/Linux tools ported on Windows, and generally all software packages where the localization files can readily be accessed. If you rename those to prevent the application from finding them, the fallback language will most probably be English.

Resources