How do I exit nvim? (neovim) - neovim

When it first opened, it said:
~ type :help nvim<Enter> if you are new!
~ type :checkhealth<Enter> to optimize Nvim
~ type :q<Enter> to exit
~ type :help<Enter> for help
But when I type :q Enter it just appears in the body?
How do you stop nvim without running pkill nvim?

Vim / Neovim has different modes :
Normal mode : you can't insert text, only use commands
Insert mode : you can type/modify/suppress text => use i key to enter in Insert mode
Visual mode : mode to select text
When you type :q, you were in Insert mode => press Espace to return in Insert mode then quit Vim/Neovim with :q command.

Press Escape. You probably activated insert mode.

Related

VsCode Vim Extension command to enter insert mode

I am wondering what is the vim command that one can use to enter the insert mode? In other words, what command is executed when you press "i" from normal mode. I want to use this command to construct custom actions using "extension.multiCommand.execute". In particular, I want to bind cmd+D in visual mode such that after selecting a text, pressing cmd+D will first put me in the insert mode without changing the selection and then will add another cursor each time I press cmd+D to the next found instance of the selected text.
Thanks

Is there a particular key to enter one character and exit insert mode in vim vscode extension?

I find myself adding a single letter during edits. Is there any way to add a character and exit insert mode just like replacing r but not deleting the character in Vs code vim extension?
pressing i <character> <Esc> each and every time defeats the purpose of being productive.
I have also looked for mapping and tried but not sure how they work.
Any help is appreciated.
From normal mode, you can put yourself in insert mode, type a space, exit back to normal mode, then put yourself in replace mode. That way you find your cursor on a blank space in replace mode, where you can simply type the character you want to add.
Here's how to do it (replace "your-desired-mapping-here" by the mapping that you like, for example: M)
vscode vim plugin way: (add this to your settings.json)
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<your-desired-mapping-here>"],
"after": ["i", " ", "<ESC>", "r"]
}
]
vim way: (add this to your .vimrc)
nnoremap <your-desired-mapping-here> i <esc>r
note: please notice the space after i in the vim way.

Start fish shell in vi insert mode?

Using fish_vi_key_bindings, fish shell starts in normal mode. How can I change the default start to insert mode?
fish_vi_key_bindings takes an argument to indicate the initial mode.
That means fish_vi_key_bindings insert will do what you want.

What are these things on my command line?

Can someone please tell me why do I get these weird characters as I type in my command line? If I press down a key I get ^[ and things like it.
Also, how can I quit vim mode? I can't click anywhere or make changes to the text.
This happens because you are in insert mode and it is expecting characters, so it converts the up and down buttons to those characters.
To quit vim:
Hit the Esc key; that goes into command mode. Then you can type
:q to quit (short for :quit)
You can find more info here.

gvim: passing the visually-selected text to the command line

I use gvim to store recipes of commands that I will execute, depending on output. Currently, I select the text in gvim and paste the commands into a terminal console, but I bet there's a way I can pass the visually selected range into a command-line for execution.
Assuming you mean the Vim command line:
(if you mean the OS command line, see below).
For parts of lines (i.e. no end of line character), you could do something like this:
" Visually select lines, then:
y:<C-R>"<ENTER>
where <C-R> means press Ctrl+R. The y 'yanks' the selected text, the : enters command mode, <C-R>" pulls the contents of the " (last yanked text) register onto the command line and <ENTER> (obviously) runs the command.
If you want to do line-wise stuff, it's a bit more complicated (as the command line doesn't like ^Ms in the command). I'd recommend something like this in your vimrc:
function! RunCommands()
exe getline('.')
endfunction
command -range RunCommands <line1>,<line2>call RunCommands()
vmap ,r :RunCommands<CR>
Select the lines (after restarting vim) and press ,r.
Another way that you may find useful is to copy the lines you want, hit q: to open the command line window and paste the lines you want into there and then move the cursor over the line you want and press ENTER. This has the advantage that you can edit the command before pressing ENTER. It'll only run one command at a time.
If you mean an (e.g.) Windows or Linux command line:
Use the function I listed above, but instead of:
exe getline('.')
use
call system(getline('.'))
or, if you want to see the result:
echo system(getline('.'))
or
echomsg system(getline('.'))
For more information:
:help :echo
:help :echomsg
:help :messages
:help :vmap
:help :command-range
:help :command
:help :function
:help c_CTRL-R
:help :exe
:help getline()
:help system()
If you are using the vim GUI, you can do set guioptions+=a. This way, any highlighted text inside gvim in visual mode gets pasted to a clipboard.