Why does gvim start every new line with TAB? - vim

I'm using gvim under Windows (version 7.3.46)
Everytime when I press o to start a new line, gvim starts the line with a TAB character.
When I set :se expandtab the TAB is changed into 8 spaces.
I tried everything to disable the starting TAB without success:
set noautoindent
set nosmartindent
set nocindent
I'm also using vim under Linux and didn't have such a problem.
THX

Related

Bad indentation vim from the clipboard

Update: thank all of you, I fixed it.
We have to use this in the .vimrc file.
set pastetoggle=<F2>
I'm still new using vim, when I try to paste something from the clipboard, vim does a bad indentation.
Example:
VIM:
line
line
line
Original:
line
line
line
Now, its important to say that I'm using the new terminal in windows, using powershell.
Thank you.
you can try to enable the paste option:
set paste
Depending on which OS and which terminal emulator you are in, you might be able to use bracketed paste mode. Bracketed paste is available by default in vim since version 8.
I had an issue setting it up on my system and here is a setup that user938271 suggested me on vi.stackexchange. Add this to your ~/.vimrc:
" Activate bracketed paste in tmux
if &term =~ "screen"
let &t_BE = "\e[?2004h"
let &t_BD = "\e[?2004l"
exec "set t_PS=\e[200~"
exec "set t_PE=\e[201~"
endif
Replace "screen" by the output of:
echo $TERM
from your terminal.
It is also important to set the filetype beforehand because of the level of indentation and its rules change for different file types. For example:
:setf java
or
:setf c

How do I get different builds of vim to ignore parts of the ~/vimrc that they do not the the plugins for?

My centos 7 has two vim binaries:
/usr/bin/vi
/usr/bin/vim
When launching either of them they bring up:
VIM - Vi IMproved
version 7.4.1099
From searching around online I believe that these two versions are vim and vim-minimal. The problem is that vi and vim-minimal interpert the ~/.vimrc differently. When opening vim its great. When opening vim-minimal I get lots of errors. Below is a representation of my ~/.vimrc file:
set number
set nowrap
set modeline
set clipboard=unnamedplus "Enables mouse center clip pasting, while holding shift, in insert mode.
"Below sets up the mouse in such a way that allows vi split screen resizing while in tmux and screen.
set mouse+=a
if &term =~ '^screen'
" tmux knows the extended mouse mode
set ttymouse=xterm2
endif
""""""""""""""""""""""""""""""""""""""""""""""""
""" User Defined Functions
""""""""""""""""""""""""""""""""""""""""""""""""
"Opens up sage specific work in new tabs
fu! Setup1()
:bd!|e /home/me/example1.h | vsplit /home/me/example1.cc
:tabnew /home/me/example2.h | vsplit /home/me/example2.cc
:tabnew /home/me/example3.h | vsplit /home/me/example3.cc
:tabnew /home/me/example4.h | vsplit /home/me/example4.cc
:tabnew /home/me/example5.h | vsplit /home/me/example5.cc
:tabnew /home/me/example6.h | vsplit /home/me/example6.cc
endfunction
"Opens up the most edited rc files in new tabs
fu! RCS()
:bd!|e ~/.cshrc
:tabnew ~/.vimrc
:tabnew ~/.tmux.conf
endfunction
The problem is my user defined functions. When /usr/bin/vi is opened it opens all of the documents in my two functions in new tabs. A resonable workaround would be to not use /usr/bin/vi but it is what git opens.
Ideally I would be able to have an if statement that checks what binary is running this rc file. Is that possible?
You can configure git to use the editor of your choice. You can set the environment variable GIT_EDITOR or you can set a configuration file with git config --global core.editor /usr/bin/vim to set the core.editor variable.
If neither of those is set, it may fall back to the VISUAL environment variable. On that note, you will likely want to set that in your ~/.bashrc as a more system-wide solution so other utilities that may want to open an editor default to /usr/bin/vim over /usr/bin/vi
The following blog post discusses how to degrade vimrc for different builds of vim that may have different packages and different capabilities (and thus react to vimrc differently):
gracefully degrading .vimrc
(answer provided by max630 in the comments to my question)

vim + tmux visual mode not highlighting

When I run vim in tmux, the syntax highlighting works fine except for the visual mode, it works but doesn't change the colors of the selected text, which I find quite annoying.
The problem stays the same even when I switch the colorscheme(I am currently using molokai)
I have the option set t_Co=256 on my vimrc
My .tmux.conf file is the same as the t-williams.conf example(just added the line "set -f default-terminal "xterm"")
I already tried some solutions to problems related to the 256 color support
any tips?
The recommended setting for tmux is
set -g default-terminal "screen-256color"
and you don't need
set t_Co=256
in your ~/.vimrc.
Make sure your terminal declares itself as a 256 color supported terminal (for example, xterm-256color). This will set the TERM in bash, which is read by tmux, and will automatically set the default-terminal setting to screen-256color.
For example, in the Terminal on OS X you can change this in the settings under the "Advanced" tab. The "Declare terminal as" option:

Pasting copied text to vim encoding issue

I copy some russian text from browser to vim then in insert mode pasting it via CTRL-R + * and getting a whole bunch of unreadable characters. I tried to set some fileencoding encoding and termencoding to utf-8 but that did not work.
My OS is Ubuntu 12.04
I use standard bash terminal
The problem appears only in non-gui vim version.
these are my .vimrc settings:
set termencoding=utf-8
set encoding=utf-8
set fileencoding=utf-8

vim from terminal always defaults colorscheme and how to start gvim in fullscreen?

I'm on windows 7. I've installed vim73 which also comes with gvim.
I downloaded a colorscheme and set it like this in my _vimrc file which lies in the root of my c:\program files\vim
:colorscheme wombat
When I run gvim the colorscheme works but when I execute vim from DOS then I just runs the default colorscheme. When in vim off of DOS if I type :colorscheme wombat nothing happens.
One last thing when I open gvim how can I make it open fullscreen.
Thanks
To answer your second question and if you're on windows you can use:
autocmd GUIEnter * :simalt ~x
in your _vimrc to start gvim in fullscreen.
I can only guess why your colorscheme does not work inside your windows terminal, but maybe the terminal does not support the color range used by the scheme and it defaults to standard colors.
Maybe this documentation can help you.

Resources