LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-12-2018, 05:32 PM   #1
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 205

Rep: Reputation: 13
Editing the .vimrc file


Linux and vim novice. I have learned the file .vimrc can be used to control the behavior of vim. Several hours of searching has not revealed a site that describes things that this file can do and how to do them.

My first goal is to change the highlighting for text found with a search. On my computer the found text has yellow highlight with white text. To my eyes it is impossible to read.

First: Please advise as to where I can find a tutorial on editing .vimrc.

Second: What would I put in that file so that the highlight is yellow but the text is black?
 
Old 04-12-2018, 08:09 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,323
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
This looks like a good place to start: https://dougblack.io/words/a-good-vimrc.htm
 
Old 04-13-2018, 01:44 AM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,224

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Just change the whole color scheme.

Try
Code:
:color desert
for one that's popular and included.

More specifically how to change the color of the text in the highlight? Well, almost the exact same question was asked here:

https://stackoverflow.com/q/7103173
 
Old 04-13-2018, 04:16 AM   #4
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
As the OP asked for the /home/user/.vimrc file, I suggest, that the color scheme and syntax-highlighting be set in the configuration file. I found these settings a hundred years ago and do not remember where they come from.

Code:
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

colorscheme koehler
" alternative color scheme
" colorscheme pablo
:hi SpellBad guibg=#ff2929 ctermbg=lightgreen ctermfg=black
My self-compiled vim does currently not have a help-file. But normally, a command like :help color or :help highlight, should show some usefull information.
Edit: I just recompiled vim, the help-files are there alright, and yes... try :help with anything, even :help vimrc ! It is always better than you thought, at first.

Last edited by Michael Uplawski; 04-13-2018 at 04:22 AM. Reason: help-files.
 
Old 04-13-2018, 04:19 AM   #5
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by frankbell View Post
This looks like a good place to start: https://dougblack.io/words/a-good-vimrc.htm
Check URL. 404 File not Found.
 
Old 04-13-2018, 10:55 AM   #6
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 205

Original Poster
Rep: Reputation: 13
Command :version produces this first line:

Quote:
VIM - Vi IMproved 7.4 (2013 Aug 10, compiles Aug 2 2017 00:45:39)
Please try to forgive typos as I cannot copy/paste from the Linux machine to here. (But do not ignore typos, it may be accurate here but wrong in my vimrc file.) The .vimrc looks like this:
Quote:
set expandtab
set shiftwidth=4
set softtabstop=4
#
# Set highlight and background for search results
hi Search cterm=NONE ctermfg=desert ctermbg=darkblue
# below for GUI
# guibg=desert guifg=darkblue
When vim starts it complains about lines 4, 5, 7, 8 with comments such as:
Quote:
Line 4:
E749: empty buffer
Line 5:
Trailing characters: #Set highlight and background for search results.
I did look that up and found that the # (hash or pound character) is the comment character. Evidently, as implemented on this computer, VIM does not like it.

The phrase:
Quote:
ctermbk=darkblue
looks ok but:
Quote:
ctermfg=desert
has the text desert highlighted in red with white text. I suspect it does not like desert. However, I found directory:
Quote:
/usr/share/vim/vim74/colors
In there are 18 color files named *.vim and both desert and darkblue are present.

Sometimes I miss the obvious but I do note that the colors are found as noted above and that this directory:
/usr/share/vim/vimfiles/colors
is empty. Might that be important? It is write protected from the user. So, ..., how can I discover all the places VIM looks for files that I can configure/edit?

Edit: color list:
I cannot find a list of all the colors than vim recognizes. And such a list really should have a sample of each color. Does anyone know where to find such a list?

Last edited by bkelly; 04-13-2018 at 11:52 AM. Reason: clarify, request color list
 
Old 04-13-2018, 12:31 PM   #7
Myk267
Member
 
Registered: Apr 2012
Location: California
Posts: 422
Blog Entries: 16

Rep: Reputation: Disabled
Quote:
Originally Posted by frankbell View Post
This looks like a good place to start: https://dougblack.io/words/a-good-vimrc.htm
https://dougblack.io/words/a-good-vimrc.html

Link fixed.
 
Old 04-20-2018, 11:04 AM   #8
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
https://wiki.archlinux.org/index.php/Vim#Configuration
 
Old 04-20-2018, 11:14 AM   #9
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,224

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Start every .vimrc with these lines:

Code:
scriptencoding utf-8
if filereadable(expand('$VIMRUNTIME/defaults.vim'))
	unlet! g:skip_defaults_vim
	source $VIMRUNTIME/defaults.vim
endif
On Vim 8, that will give you the new, saner defaults.
 
Old 04-20-2018, 12:42 PM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
just one comment:
# is not the comment sign in vimrc. That's why you got those errors.
If I know well that is "
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
hi i not getting my .vimrc file in this path ~/.vimrc dina3e Linux - Newbie 6 07-31-2012 04:36 PM
Vim and my personal .vimrc file lost puskas Linux - General 5 08-31-2011 02:31 AM
[SOLVED] Common .vimrc file to all the computers on network Ajit Gunge Linux - Newbie 2 06-15-2009 08:24 PM
editing ~/.vimrc in FreeBSD jus71n742 *BSD 12 06-08-2009 10:19 PM
Slack's Example vimrc File mijenks Slackware 2 12-30-2004 10:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 11:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration