How do I get perl-support.vim to recognize Perl files? - perl

I installed perl-support.vim into ~/.vim (unzipped). When I create a new .pl file it shows me the default template, which means my installation is successful (I guess). I have already added filetype plugin on in ~/.vimrc & /etc/vimrc.
How do I enter a perl-support command?
The write up recommends typing \isu in normal mode for creating a new sub, but the moment I hit i vim changes into insert mode and nothing intended happens.
What am I doing wrong?

Make sure you've enabled ftplugins with the filetype plugin on command in .vimrc, and of course make sure that the file you're editing is recognized as a Perl file (usually, by having a known extension, but you can force the matter by issuing the command set filetype=perl. If filetype plugins aren't enabled, or if the filetype isn't recognized, then the rest of perl-support won't get loaded at all.

As recommended by hobbs, set filetype=perl works.
However, I wanted to do this everytime I open a .t test file — which my vim does not recognize as perl files because the interpreter statement is also custom.
I checked out :help syntax in vim and saw this:
mkdir ~/.vim/ftdetect
cd ~/.vim/ftdetect
vim t.vim
which contains
au BufRead,BufNewFile *.t set filetype=perl
which means: if the file extension is .t then do set filetype=perl.
This can be useful for any other custom extension.

I found I had to install Perl::Tags before most things (esp. \ commands). Installing Perl::Tags made an error message thrown by filetype plugin on go away.
cpan> install Perl::Tags # make sure you say yes to any offer to install dependancies

Related

Can't install neovim in windows

I want to have neovim. I installed it with choco install neovim in the PowerShell (admin). Then I followed a lot of tutorials, like the one of theprimeagen, but I can't get pass the first steps. Maybe is because I don't have Linux, as everybody does, but I don't think is that.
I created a folder like so: C:/users/myusername/.config/nvim. Then, in this folder I type nvim . to open the Explorer of neovim and start creating the .lua files. The problem is that I always get a stupid .nvimlog every time I enter neovim, I think is the reason why I can't install plugins correctly or remap some keys.
In the .nvimlog every time I enter neovim appears a new line that says:
ERR 2023-02-12T12:55:04.800 nvim.15716.0 terminfo_start 374: uv_tty_set_mode failed: invalid argument. And I swear I followed every tutorial in the exact way, and even without creating any file the .nvimlog is always there.
In windows, the default config directory is ~/AppData/Local, based on their official documentation. I don't know if there is a way to change that, but that is how i configured it.
To find out where your config directory is you can also use :echo stdpath('config').

How do I change the path of pylint in coc.nvim?

I am using the CoC extension in Neovim. When I import some python modules I have installed, pylint shows an error, as if they were not installed, even though they are. I know this because the file executes correctly (and I installed them previously). After doing :CocCommand workspace.showOutput Pyright, I get the path of the version of python being used, and of course it is not the one I want. But I don't know how to change it.
Two ways:
activate the correct Python used in your project, make sure which python points to the correct path, launch nvim
set the path in coc-settings.json by python.pythonPath, default is python that use from $PATH.

Neovim error: E492: Not an editor command: PlugInstall

OS: Ubuntu 18.04.3 LTS
I just installed neovim using sudo apt-get install neovim and added the folder and file ~/.config/nvim/vim.init. At this moment the file has no content, but when I open up nvim and type :PlugInstall I get error: E492: Not an editor command: PlugInstall. I am clueless, what is going wrong?
I think you are trying to use vim-plug without previously installing it.
I changed my plug#begin to
call plug#begin('~/.local/share/nvim/site/autoload/plug.vim')
and it worked for me now
I followed this and it worked: https://github.com/junegunn/vim-plug/wiki/tutorial
I also wrote call plug#begin('~/.config/nvim/plugged) and made a directory at that location. Then the reload command is also source ~/.config/nvim/init.vim where init.vim is the configuration file. And then I just ran :PlugInstall and it worked :D
I got this error too, but in my case I was typing :pluginstall instead of the case-sensitive :PlugInstall and you have to use the correct case or it won't work. Oddly, :PlugUpdate was able to work before :PlugInstall but that was just because I typed the case correctly.
I see I have the vim.plug correctly installed here
~/.vim/autoload/plug.vim
I also created a "plugged" folder here and I see this is where vim-plug put the downloaded files from running :PlugInstall
.vim/plugged
To be overly pedantic, I typed 'cd' to get to the user directory, then cd .vim to go into my dotted .vim folder, then "mkdir plugged" to create the plugged directory. Not sure if this was 100% necessary or if :PlugInstall would have created it by itself.
I also needed to :source ~/.vimrc between adding addition plug line items and typing :PlugInstall, so make sure you "source" or you can also completely quit and restart your Vim so it will reload your .vimrc file, otherwise it won't know anything about your file edits.
I'm on a Mac. I installed vim-plug for standard vim and this gave me this file
~/.vim/autoload/plug.vim
My .vimrc is this:
" add line numbers
set number
call plug#begin()
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" Make sure you use single quotes
Plug 'tomasiser/vim-code-dark'
Plug 'tpope/vim-sensible'
call plug#end()
I had the same problem and come here for leave my contribution ( I hadn't find this solution in anywhere ). In my case, it's caused by permissions in my linux. I always start my vim for ocults archives with:
sudo vim .vimrc
In this case, the Vim just use the default commands ( I don't know why but I think this is by the security ). If you just run:
vim .vimrc
All the user commands will be able.
In my case, I had multiple terminal windows open. I still had the Vim window open after installing vim-plug in another window. Solution was to close and re-open Vim.
Instead of
call plug#begin()
I did
call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged')
Worked 100%
If you have followed the steps in https://github.com/junegunn/vim-plug, but still didn't work.
Try run ':source ~/.config/nvim/vim.init' in vim (not source ~/.config/nvim/vim.init in shell).
Make sure git is installed.
In my case, I was trying to do :PlugInstall in a docker container and did not have git installed. I installed git, and it worked.

Script in PATH Mac OSX terminal not working

I have the following script in my /path/to/startupscripts directory, so I can open the emacs GUI with the command 'emacs':
#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "$#"
I edited my ~/.bash_profile and added the following line
export PATH=/path/to/startupscripts/emacs:$PATH
However, the script is not working because when I type in 'emacs' into the command line emacs still opens within terminal and not the GUI like I want. Also, when I am in the /path/to/startupscripts directory and I can execute and run the script with
chmod +x emacs
./emacs
but even when I type 'emacs' afterwards it still opens within terminal. I am a bit of a beginner, and I think I am missing something painfully obvious.
The PATH should contain a directory name where your script(s) can be found, not the name of your individual script.
You probably need to source your .bash_profile:
source ~/.bash_profile
No changes made in your profile will be applied unless you source the profile or log out and back in.
Aside from that every looks like it should work.
However you may want to consider just using an alias instead of a script for this. This can be done by adding this to your profile:
alias emacs=/Applications/Emacs.app/Contents/MacOS/Emacs
That's probably a cleaner way to get the functionality you want without adding more to your PATH variable.
I hope that helps! [insert obligatory comment about how you should be using vim and not emacs :P]

External editor for IPython notebook

I am using IPython notebook and I want to edit programs in an external editor.
How do I get the %edit file_name.py to open an editor such as Notepad++.
Running %edit? will give you the help for the %edit magic function.
You need to set c.TerminalInteractiveShell.editor, which is in your ipython_config.py. I'm not quite sure where this is located in Windows; on OS X and Linux, it is in ~/.ipython. You'll want to set the variable to be the full path of the editor you want.
Alternatively, you can create an environment variable EDITOR in Windows itself, and set that equal to the full path of the editor you want. iPython should use that.
I'm using Windows 7 and 8 (and 10TP) and Python 3.4.2.
I started with ipython locate to tell me where ipython thought config files suggested elsewhere should be. When I saw it was different I read around and came up with the following:
On my system, the ipython locate gave me c:\users\osmith\.ipython, not the _ipython you'll see mentioned in the YouTube videos done with Windows XP,
Look in the directory ipython locate specifies for a profile directory; if you aren't actively doing anything with ipython profiles, it should be .ipython\profile_default, if you are using profiles, then I leave it to you to s/profile_default/${YOUR_PROFILE_NAME}/g
Check the profile_default directory for a ipython_config.py file, if it's not there, tell IPython to initialize itself: ipython profile create
Open the config file in a text editor,
If you are the kind of person who hasn't messed around with their console overly much and installs things in standard places, you can skip straight to this step by typing: ipython profile create followed by start notepad .ipython\profile_default\ipython_config.py.
Search for the string c.TerminalInteractiveShell.editor,
The comment above this indicates you can also use the EDITOR environment variable, but hard coding file paths never hurt anyone so lets do eet:
Copy the line and remove the leading hash and spaces from the copy.
Replace the text between the apostrophes ('notepad') with the path of our desired editor, e.g.
c.TerminalInteractiveShell.editor = 'c:/program files (x86)/noddyeditor/noddy.exe'
There is a catch here, though; some modern editors get a bit fancy and automatically and, when invoked like this, detach from the console. Notepad++ and Sublime Text, for example. Sublime accepts a "--wait" option, which works some of the time; this tells the command invocation to hang around until you close the file, for some definition of until and some other definition of close.
However, the following setting will work most of the time for sublime text:
c.TerminalInteractiveShell.editor = '"c:/program files/sublime text 3/subl.exe" --wait'
(assuming c:\program files\ is where your sublime text 3 directory is)
Try the 'Pycharm' editor
This works for me.