Vim cursor going outside of character bounds in normal mode - vim

Some setting changed on my vim. In normal mode, I can now click anywhere and my cursor will go there. (This is in normal mode.)
The behavior used to be that if I clicked past the end of the line, the cursor would go to the last character of the line.
I hope I've explained this sufficiently, but is there a way to get the old behavior back?
Thanks!

You probably set the option virtualedit somewhere. To turn it off for the instance you can use :set virtualedit=. Or to permanently disable it remove it from your vimrc.

The feature is call virtual edit. You can disable this with:
:set virtualedit=
See :h 've' for more information.

Related

Add whitespace to current line in vim

I fairly often find myself in a situation like this:
I'd like to start typing on the line on which my cursor is currently. However, in order to get to the correct indentation level, I'd have to press TAB several times.
Usually I'd press ddO (delete current line and insert a new one above the cursor), which resets my indentation position to the right place:
But that seems like an odd way to go about adding the correct amount of whitespace.
Is there a better way that I'm overlooking?
When in normal mode, you can use cc or its synonym S. If you are already in insert mode, Ctrlf is the default key for this, but that can be changed by altering cinkeys (see :h cink for details).
See also this answer on the Vi/Vim stack
Kevin mentioned some shortcuts, but another method is <C-i> (indent) and <C-d> (dedent) in insert mode.

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.

spf13-vim disable tab highlighting

I'm an absolut vim-newbie so I thought I'll try it with some preconfigured distribution like spf13-vim. So to my question, I would like to disable the "tab-highlighting" because I find it kind of distracting...
I think this picture should make clear what I mean
Put a line below in your ~/.vimrc.local or ~/.vimrc.before.local to disable indent guide by default. You can <leader>ig as well.
let g:indent_guides_enable_on_vim_startup = 0
You can toggle them on/off with ,ig.
write set nolist in your .vimrc.local to turn it off.
see :h list
'list' boolean (default off)
List mode: Show tabs as CTRL-I is displayed, display $ after end of
line. Useful to see the difference between tabs and spaces and for
trailing blanks. Further changed by the 'listchars' option.

Using makefiles and vim without prompt

I'm using vim and im doing a lot of
:make
within vim. The only thing that is really annoying is that I have to press ENTER twice to jump back to the editor. I just want to go directly back if everything worked out fine. And I want to see the error once and press a key to jump directly to the error line.
Any ideas?
This is known as the hit-enter prompt:
If you accidentally hit or and you want to see the displayed
text then use |g<|. This only works when 'more' is set.
To reduce the number of hit-enter prompts:
Set 'cmdheight' to 2 or higher.
Add flags to 'shortmess'.
Reset 'showcmd' and/or 'ruler'.
Also, I'm sure you are aware of the quickfix window (:copen) to navigate errors/messages?
This can happen when the 'cmdheight' varible is < 2.
I had the same problem. This is a simple solution that seems to work:
map <F2> :silent make^M
Now I just hit the F2 key to compile and the annoying prompt is not so annoying.
Not sure if it would help you, but if you're on Windows you could try:
:set makeprg=start\ make
I think this will break the errorfile setting though.
See:
:help make
:help !start

Vim change block cursor when in insert mode

Not sure what the terminology is for it but on Vim the 'cursor' is always like an insert/replace cursor instead of the blinking line cursor I'm used to in other gui editors. Is there any way to change this when in insert mode?
I know this is an old question but hopefully this will help anyone else facing the same scenario.
Actually I'm using iTerm2 and using Vim inside my terminal on Mac. And when entering to insert mode, the cursor still being a block and is kind of confusing when you are at insert mode or normal mode.
I wanted to show a thin line as cursor when in insert mode and back to block when in normal mode as MacVim does. And to do so it's pretty simple, just added this to my .vimrc file as described here:
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
But as you can see there was a delay when hitting ESC to exit insert mode back to normal mode and show the block as cursor again. So to fix it I found this:
set ttimeout
set ttimeoutlen=1
set listchars=tab:>-,trail:~,extends:>,precedes:<,space:.
set ttyfast
And now it works pretty fine as you can see:
I hope it could help any one else! 👻
The gcr option does this, although I'm not sure exactly how it needs to be set to get the results you want.
:help gcr
If you read the manual and play around with it, you should be able to figure it out.
The blinking cursor in insert mode is usually the default. Maybe the gcr option got changed in your .vimrc
This plugin for vim will actually change the cursor on the fly in iterm (and tmux)
It has a few bugs if you're in tmux, but works great outside of it: https://github.com/sjl/vitality.vim
I was connecting using iTerm on mac. It seems there is a setting in iTerm for it. Quick change and its working.

Resources