Current line number in vim not highlighted with relative line number - vim

So I have relative line numbers turned on with the gruvbox theme and I'm trying to get highlighting of the current line number that I'm on. This works by default when just enabling relative line numbers in the .vimrc of an ssh session but not otherwise. I've tried using :set cursorline but that marks the whole line not just the line number. This is on a mac btw
How it looks in an ssh vs how it looks not in an ssh session

you can enable cursorline
:set cursorline

Related

VIm - How to remove right margin

How do I remove the right margin in Vim? It seems to be adding a carriage return and line feed (column 80?) whenever I save a file as .txt or .md. This doesn't happen if I save the file with no extension, but I want to be able to edit .txt files.
I've tried :set nowrap but this doesn't have the desired effect. I also commented out everything in my .gvimrc file in case I inadvertently did something there but no luck with that approach.
The text filetype in Vim sets the textwidth option to 78 by default, which has the effect of splitting lines. If you remove the textwidth option by setting it to zero, Vim will stop splitting lines. You can remove textwidth by hand with
:set textwidth=0
or you could add something like
autocmd FileType text setlocal textwidth=0
to your .vimrc.
I was able to resolve this by commenting out the following line in the vimrc_example.vim file:
" autocmd FileType text setlocal textwidth=78
Here's the path to the file on my machine:
C:\Program Files (x86)\Vim\vim80\vimrc_example.vim
I'm using gVim.
With the current monitor sizes (4K and bigger) the 78 character rule is not valid anymore (valid in the era before the 21" CRT monitors)
I tried the solution by Jon, but it did not work for git commit messages.
I had to change the .vimrc line to
autocmd FileType * setlocal textwidth=0
Now it works for any file type.

Why am I having trouble to embed "set syntax" into a file?

I have read the help and examples, but still don't know what I'm doing wrong.
When I manually enter :set syntax=javascript, I get the syntax highlighting I want.
But when I edit the first line of my file to read:
/* vim: set syntax=javascript: */
nothing happens.
When I split that line into 3 lines:
/*
# vim: set syntax=javascript:
*/
I get some limited syntax highlighting, not as good as with manual command. I can write syntax=anything there and it makes no difference.
(Vim version 7.4.160, Centos 7)
Lines of the format:
/* vim: set syntax=javascript: */
are called modelines in Vim. In order for Vim to process them, you must have the modeline option toggled on.
To see if modeline is enabled, run this ex command:
:set modeline?
If it returns nomodeline, you can enable it by adding the following in your ~/.vimrc:
set modeline
Vim will look for a modeline in the first 5 lines of the file, by default. You can set the number of lines that will be searched with e.g.:
set modelines=10
See :help modeline for details.

How could I enable cursor line only for gvim?

I want to enable cursorline only for gvim but disable it for vim in TUI, I tried this in .vimrc
if has("gui_running")
set cul
else
set nocul
endif
but it doesn't seem to work.
The .vimrc gets read by gvim and vim while the .gvimrc gets only read by gvim. As the docs say:
The gvimrc file is where GUI-specific startup commands should be placed. It
is always sourced after the |vimrc| file. If you have one then the $MYGVIMRC
environment variable has its name.
While your command should do the trick, I'd place the set cul command in my .gvimrc.
This will also help your .vimrc being cleaner and you don't need gui_running checks anymore.

Set working in file but not in .vimrc

When I put set scroll=10 in my .vimrc it does not work, but it does work when I enter the command in command mode.
I have many other commands in my .vimrc, what reason could there be for this set to not be getting through? It is the last line in my .vimrc.
:verbose set scroll?
should tell you which plugin script has last modified that option. If you don't find the culprit this way, you could workaround by setting it at the last possible moment by putting this in your ~/.vimrc
:autocmd VimEnter * set scroll=10

How do I configure .vimrc so that line numbers display in netrw in Vim?

I'm using netrw to read directory listings in Vim, and I would like to display line numbers in my netrw tabs (so I can use :24 to navigate through directory listings faster). I'm using "set number" in my vimrc to enable line numbers when editing files, but this does not display line numbers in netrw.
When in netrw, if I type the command ":set number", the line numbers display, but as soon as I change directories the line numbers go away.
Is there a configuration option I can put in .vimrc that will make line numbers show up in netrw windows?
From autoload/netrw.vim in the runtime:
call s:NetrwInit("g:netrw_bufsettings" , "noma nomod nonu nobl nowrap ro")
s:NetrwInit overrides a variable only if it is not defined.
Therefore put let g:netrw_bufsettings = 'noma nomod nu nobl nowrap ro' into your vimrc and it should be ok.

Resources