How to remove row lines in vim? - vim

How do i remove the row lines at the start of the line? I typed the command
:s/^/# /
while in command mode and it suddenly appeared. I typed the command again, but it's still in my editor. I was trying to comment out a few blocks of code. This is the stackoverflow page I was following: What's a quick way to comment/uncomment lines in Vim?
Please see the image below to see what I'm pertaining to. Thanks in advance!

Vim highlights the current search pattern; this is the 'incsearch' option; either you have it explicitly turned on in your ~/.vimrc, or you use a recent Vim 8 version that has this enabled by the defaults.
Check with :hi IncSearch; it should show the same white-underscore-onblack formatting as your screenshot. You can also use a :hi command to customize this (or choose a different colorscheme).
To turn this off, use
:nohlsearch
You can shorten that to :noh; some people also define a mapping to quickly clear this. Alternatively, you can also search for something else.

Related

Neovim: How do I set guicursor to make the cursor blink?

The cursor blinking is off by default in Neovim and I want it back. I have tried to apply different arguments to guicursor, but didn't succeed. Since I want it to blink the same way in every mode, I think, I need something with the letter 'a' in it.
Here's what I have tried so far:
:set guicursor=a:blinkwait700-blinkon400-blinkoff250 (I also tried with 'i')
:set guicursor=a:blinkon100 (as the opposite of a:blinkon0 which switches it off)
I've already looked into the help but it didn't help me unfortunately.
Update:
What is peculiar is that :set guicursor=a:blinkon100 enables the blinking in gVim, but not in Neovim.
From neovim 0.2 onwards, setting guicursor does achieve the desired effect:
" Enable blinking together with different cursor shapes for insert/command mode, and cursor highlighting:
set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50
\,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor
\,sm:block-blinkwait175-blinkoff150-blinkon175
Find more by typing :help 'guicursor' from inside nvim.
For more info, see the official wiki
Finally, if you use st, you can patch it to get this working:
https://st.suckless.org/patches/blinking_cursor/
EDIT: I noticed from the comments of the first answer that OP was talking about nvim-qt, for those interested in that, a fix for it has been merged at the beginning of this year.
If you are using the st terminal by Suckless then that does not support cursor blinking I belive, otherwise if your terminal does support it try setting the option let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 in your init.vim file. You could also pass that on the command line such as NVIM_TUI_ENABLE_CURSOR_SHAPE=1 nvim.

How to avoid ; repeat command in vim highlighting text?

Like most, i have enabled hlsearch in vimrc.
so, all my text searches are highlighted.
But, when i use 'f' command to move to a letter and use ';' command to repeat, vim highlights all the occurrences of the character overriding my previous text search.
how can i make vim just move to the character without interfering with my text search keyword?
You've likely found a bug in the ft_improved plugin; you should report that to the plugin's issue tracker.
Alternatively, you can also check out an alternative; Extended-FT and Fan,FingTastic are two. Also, using vims f command over multiple lines has some light-weight implementations in the answers.

GVIM : in /root/.vimrc i have ":colorscheme desert" which worked, but where would i have found this value if someone hadn't told me?

So in GVIM i changed the color-scheme to
desert
but i never understood how to find this line
:colorscheme desert
so i could place it in
/root/.vimrc
file.
where would i have found out about " :colorscheme desert " ?
You could read the help (it is quite long and very detailed)
:h
Opens up to the main help for vim. Under getting started you will see the following. You might have to scroll down a bit (Use Control+f to page down)
usr_toc.txt Table Of Contents
Getting Started
usr_01.txt About the manuals
usr_02.txt The first steps in Vim
usr_03.txt Moving around
usr_04.txt Making small changes
usr_05.txt Set your settings
usr_06.txt Using syntax highlighting
usr_07.txt Editing more than one file
usr_08.txt Splitting windows
usr_09.txt Using the GUI
usr_10.txt Making big changes
usr_11.txt Recovering from a crash
usr_12.txt Clever tricks
It seems the that usr_06.txt is related to syntax highlighting so that might be worth reading. So type :h usr_06.txt or <c-]> (Control+]) to jump to that file when your cursor is on top of it.
Once you are in there you can look at the table of contents again.
06.1 Switching it on
06.2 No or wrong colors?
06.3 Different colors
06.4 With colors or without colors
06.5 Printing with colors
06.6 Further reading
Different colors seems to be what you want. So type :h 06.3 (or <c-]>) and the first paragraph talks about changing the colorscheme.
Control+] jumps to a tag and is talked about in :h tagsrch.txt (And on the line "Jump to a subject" immediately as you open :h)
The help have an auto completion feature.
So you can type, :help color followed by Ctrl+d. You won't necessary find the good entry right of the bat but it should put you on the right track. It would have shown you a colorscheme option.
An alternative is to use :helpgrep. :helpgrep color should give you a list of help file wich contains the string color.
On Debian Linux, it's part of the the vim-runtime package and sits in /usr/share/vim/vim73/colors/desert.vim. You can list contents of this direcory for more options. I don't think they have hard-coded color schemes in vim itself, so vim help will not list them for you.
I suppose like most other vim plugins, customized color schemes can also be put in ~/.vim directory.

How to autocomplete file paths in Vim, just like in zsh?

In Zsh, I can use filename completion with slashes to target a file deep in my source tree. For instance if I type:
vim s/w/t/u/f >TAB<
zsh replaces the pattern with:
vim src/wp-contents/themes/us/functions.php
What I'd like is to be able to target files the same way at the Vim command line, so that typing
:vi s/w/t/u/f >TAB<
will autocomplete to:
:vi src/wp-contents/themes/us/functions.php
I'm trying to parse the Vim docs for wildmode, but I don't see what settings would give me this. It's doing autocompletion for individual filenames, but not file paths. Does Vim support this natively? Or how can I customize the autocomplete algorithm for files?
Thanks for any advice!
-mykle-
I couldn't find a plugin to do this, so I wrote one. It's called vim-zsh-path-completion. It does what you're looking for, although via <C-s> rather than <Tab>. You can use it with <Tab> for even more control over what matches, though.
It's got bugs, but for basic paths without spaces/special characters, it should work. I think it's useful enough in its current state to be helpful. I hope to iron out the bugs and clean up the code, but I figured I'd start soliciting feedback now.
Thanks for the idea!
Original (wrong) answer, but with some useful information about Vim's wildmode.
Put the following in your .vimrc:
set wildmenu
set wildmode=list:longest
That will complete to the longest unique match on <Tab>, including appending a / and descending into directories where appropriate. If there are multiple matches, it will show a list of matches for what you've entered so far. Then you can type more characters and <Tab> again to complete.
I prefer the following setting, which completes to the first unique match on <Tab>, and then pops up a menu if you hit <Tab> again, which you can navigate with the arrow keys and hit enter to select from:
set wildmode=list:longest,list:full
Check out :help wildmenu and :help wildmode. You might also want to set wildignore to a list of patterns to ignore when completing. I have mine as:
set wildignore=.git,*.swp,*/tmp/*
Vim doesn't have such a feature by default. The closest buil-in feature is the wildmenu/wildmode combo but it's still very different.
A quick look at the script section of vim.org didn't return anything but I didn't look too far: you should dig further. Maybe it's there, somewhere.
Did you try Command-T, LustyExplorer, FuzzyFinder, CtrlP or one of the many similar plugins?
I use CtrlP and fuzzy matching can be done on filepath or filename. When done on filepath, I can use the keysequence below to open src/wp-contents/themes/us/functions.php (assuming functions.php is the only file under us that starts with a f):
,f " my custom mapping for the :CtrlP command
swtuf<CR>
edit
In thinking about a possible solution I'm afraid I was a little myopic. I was focused on your exact requirements but Vim has cool tricks when it comes to opening files!
The :e[dit] command accepts two types of wildcards: * is like the * you would use in your shell and ** means "any subdirectory".
So it's entirely possible to do:
:e s*/w*/t*/u*/f*<Tab>
or something like:
:e **/us/f<Tab>
or even:
:e **/fun<Tab>
Combined with the wildmode settings in Jim's answer, I think you have got a pretty powerful file navigation tool, here.

Search highlighting (hlsearch) not working in vim

I have a problem with search highlighting in vim. I have used it before but currently it does not work at all.
I have entered :set hlsearch, which is also in my .vimrc file.
I have entered :set hlsearch? and the result is hlsearch, indicating that I have successfully turned the option on. (right?)
I am running vim and not vi, so that is not the problem.
I have searched around but only found people asking about turning OFF search highlighting.
I would appreciate any input as this has been driving me nuts. Thanks!
Edit: highlighting also doesn't work for spellcheck, so evidently it's something global about highlighting.
When you have problems with multiple highlightings (like search and spell in your case), first check the defined highlightings with
:hi
If any groups are wrong or off, check your :colorscheme, and maybe try another.
In the console, color problems are often related to the number of available colors, a hairy problem. Check with
:set t_Co?
Another good tool for checking problems with individual syntax items is the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin.

Resources