Vim came as default on my msys2 version but I don't see the ~/.vimrc file nor ~/.vim/ directory
any thoughts
just place a file in /etc/vimrc
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram#vim.org>
" Last change: 2011 Apr 15
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" 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
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
Related
When I run vim it puts me in --REPLACE-- mode, how I put it in command mode or insertion mode.
( And how to activate these commands by default when I run vim?
- :set nu
- :set cc=80
)
vimrc
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=ucs-bom,utf-8,latin1
endif
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
"set ai " always set autoindenting on
"set backup " keep a backup file
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
" Only do this part when compiled with support for autocommands
if has("autocmd")
augroup redhat
autocmd!
" In text files, always limit the width of text to 78 characters
" autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
" don't write swapfile on most commonly used directories for NFS mounts or USB sticks
autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
" start with spec file template
autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec
augroup END
endif
if has("cscope") && filereadable("/usr/bin/cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add $PWD/cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
" 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
filetype plugin on
if &term=="xterm"
set t_Co=8
set t_Sb=[4%dm
set t_Sf=[3%dm
endif
" Don't wake up system with blinking cursor:
" http://www.linuxpowertop.org/known.php
let &guicursor = &guicursor . ",a:blinkon0"
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 21 2016 17:00:20)
Included patches: 1-160
Recently I figured out that pressing CTRL-U locks/freezes vim in insert mode. The only CTRL-C helps to get it back. Terminal version and gvim have the same behaviour. Only in virtual console mode (CTRL-ALT-F1) the C-U works properly. Here is my .vimrc:
" This must be first, because it changes other options as a side effect.
set nocompatible
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
imap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" 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
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" Options
" =========================================================
colorscheme gruvbox
let g:gruvbox_contrast_dark = 'normal'
set background=dark
set t_Co=256
" spelling
set spell spelllang=ru_yo,en_us
set spellsuggest=10
set keymap=russian-jcukenwin
set iminsert=0
set imsearch=0
" backup
set writebackup " backup on write
set nobackup " keep a backup file
set undofile " keep an undo file
set swapfile " keep a swap file
" directories
" set autochdir
set backupdir=~/.vim/tmp/backup//
set undodir=~/.vim/tmp/undo//
set directory=~/.vim/tmp/swp//
" active editor
set nowrap
set nu
set backspace=indent,eol,start " backspacing over everything in im
set ruler " show the cursor position all the time
" cmd
set history=50 " keep 50 lines of command line history
set showcmd " display incomplete commands
" search
set ignorecase " ignore case using a search pattern.
set smartcase " override 'ignorecase' when pattern has upper case.
set incsearch " do incremental searching
" tab
" set tabstop=2 shiftwidth=2 noexpandtab " n-column tab
set tabstop=2 shiftwidth=2 expandtab " n-space character tab
" window
set splitbelow
set splitright
set winminheight=0
" folding settings
set foldmethod=indent " fold based on indent
set foldnestmax=10 " deepest fold is 10 levels
set nofoldenable " dont fold by default
set foldlevel=1 " this is just what i use
" invisible chars
set list " don't show invisible characters.
set listchars=tab:.\ ,trail:~,extends:>,precedes:<,eol:\ "¬
set nohidden " unload buffer when no longer shown in window.
set laststatus=2 " Display vim-lightline
" indent, cursor, width
set cursorline " Highlight the screen line of the cursor.
set colorcolumn=72 " Columan to highlight.
set autoindent " Automatically set the indent of a new line.
set textwidth=80
set completeopt=menuone,longest ",preview prevents immediate complete
" tab
set switchbuf=usetab " use window or tabs to find selected buff
" windows
set noea " fix window size after closing others
" sessions (^blank,help)
set sessionoptions=buffers,curdir,folds,help,options,tabpages,winsize
" Autocmd
" =========================================================
au BufReadPost *.tmpl set syntax=html
" Mappings
" =========================================================
" source and update file
nmap <F5> :so ~/.vimrc<CR>
nmap <leader>e :e<CR>
" copy filepath
nmap <silent> <F4> :let #+=expand("%:p")<CR>
" buffers
nmap <F2> :ls<CR>:b
nmap <c-w><c-t> :tabnew<CR>
nmap <c-w><c-e> :tab sp<CR>
nmap <c-w><c-b>n :tabnew %<Bar>:bNext<Bar><CR>
nmap <c-w><c-b><c-b> :bw %<CR>
nmap <c-w><c-b>w :bw! %<CR>
nmap <c-w><c-b>a :tab ball<CR>
" sessions
nmap <silent> <leader>ss :wa<Bar>exe "mksession! " . v:this_session<CR>
nmap <leader>sr :so .session.vim<CR>
nmap <leader>sc :msk .session.vim<CR>
" quit
nmap <leader>qd :qa!<CR> " quit & discard changes
nmap <leader>qq :xa<CR> " quit & write if changed
nmap <leader>qs <leader>s<leader>qd
" new vertical window
nmap <c-w><c-n> :vnew<CR>
" tab movement and switching
nmap <c-l> :tabnext<CR>
nmap <c-h> :tabprevious<CR>
nmap <c-j> :tabmove -1<CR>
nmap <c-k> :tabmove +1<CR>
" search and replace
nmap <leader>c :let #/=""<CR>
" trailing spaces
nmap <silent> <leader>dt mq:%s/\s\+$//e<Bar>:let #/=""<CR>`q:delm q<CR>
" update, write
nmap <leader>u <leader>dt:update<CR>
nmap <leader>w <leader>dt:write<CR>
cmap w!! w !sudo tee > /dev/null %
" window manipulation
nmap <c-w>== :set ead=ver ea noea<CR>
nmap <c-w>=- :set ead=hor ea noea<CR>
" shell
nmap <space> :sh<CR>
" Plugins
" =========================================================
call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go'
Plug 'mattn/emmet-vim'
Plug 'itchyny/lightline.vim'
Plug 'sheerun/vim-polyglot'
Plug 'scrooloose/syntastic'
call plug#end()
" Lightline.vim
let g:lightline = {
\ 'colorscheme': 'jellybeans',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'filename', 'readonly', 'modified' ] ] },
\}
" Syntastic
" let g:syntastic_sass_checkers = ["sassc"]
" Netrw
nmap <leader>tr <Plug>NetrwRefresh
map <leader>tf :Ntree<CR>
map <silent> <leader>f <S-CR>
let g:netrw_liststyle=3
let g:netrw_banner=0
let g:netrw_mousemaps=0
let g:netrw_chgwin=1 " open files in left window by default
" let g:netrw_keepdir=0
" let g:netrw_silent= 1
" fire up the sidebar
nmap <silent> <C-#> :rightbelow 25vs<CR>:e .<CR>
" vim-go
" disable fmt on save
let g:go_fmt_autosave = 0
" format with goimports instead of gofmt
let g:go_fmt_command = "goimports"
" additional highlight
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
" YouCompleteMe
let g:ycm_confirm_extra_conf=0
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_min_num_of_chars_for_completion=1
" Emmet-vim
let g:user_emmet_leader_key='<c-m>'
" Formats the statusline
" set statusline=%f " file name
" set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
" set statusline+=%{&ff}] "file format
" set statusline+=%y "filetype
" set statusline+=%h "help file flag
" set statusline+=%m "modified flag
" set statusline+=%r "read only flag
"
" set statusline+=\ %= " align left
" set statusline+=Line:%l/%L[%p%%] " line X of Y [percent of file]
" set statusline+=\ Col:%c " current column
" set statusline+=\ Buf:%n " Buffer number
" set statusline+=\ [%b][0x%B]\ " ASCII and byte code under cursor
" Miscellaneous
" =========================================================
nmap <leader>t :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
:set guioptions-=m "remove menu bar
:set guioptions-=T "remove toolbar
:set guioptions-=r "remove right-hand scroll bar
:set guioptions-=L "remove left-hand scroll bar
It's quite big, but the only one mapping related with C-U: imap <C-U> <C-G>u<C-U>. What's going on?
I've copied your vimrc and used it. Same effect. It's this line:
imap <C-U> <C-G>u<C-U>
which apparently causes a recursion. When commented out, <C-u> erases back to start-of-line.
Given the problem that #Jens found... you, Timur, might want to try
inoremap <c-u> <c-g>u<c-u>
That will prevent remapping (ie. an infinite recursion) from taking place.
I have started using vim editor from last 2 weeks and one problem the I face is I can't copy few bunch of codes to other editors or somewhere else however i can copy something to vim editor.
Below is my .vimrc file :-
" Automatic reloading of .vimrc
autocmd! bufwritepost .vimrc source %
" Better copy & paste
" When you want to paste large blocks of code into vim, press F2 before you
" paste. At the bottom you should see ``-- INSERT (paste) --``.
set pastetoggle=<F2>
set clipboard=unnamed
" Mouse and backspace
set mouse=a " on OSX press ALT and click
set bs=2 " make backspace behave like normal again
" Rebind <Leader> key
" I like to have it here becuase it is easier to reach than the default and
" it is next to ``m`` and ``n`` which I use for navigating between tabs.
let mapleader = ","
" Bind nohl
" Removes highlight of your last search
" ``<C>`` stands for ``CTRL`` and therefore ``<C-n>`` stands for ``CTRL+n``
noremap <C-n> :nohl<CR>
vnoremap <C-n> :nohl<CR>
inoremap <C-n> :nohl<CR>
" Quicksave command
noremap <C-Z> :update<CR>
vnoremap <C-Z> <C-C>:update<CR>
inoremap <C-Z> <C-O>:update<CR>
" Quick quit command
noremap <Leader>e :quit<CR> " Quit current window
noremap <Leader>E :qa!<CR> " Quit all windows
" bind Ctrl+<movement> keys to move around the windows, instead of using Ctrl+w + <movement>
" Every unnecessary keystroke that can be saved is good for your health :)
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" easier moving between tabs
map <Leader>n <esc>:tabprevious<CR>
map <Leader>m <esc>:tabnext<CR>
" map sort function to a key
vnoremap <Leader>s :sort<CR>
" easier moving of code blocks
" Try to go into visual mode (v), thenselect several lines of code here and
" then press ``>`` several times.
vnoremap < <gv " better indentation
vnoremap > >gv " better indentation
" Show whitespace
" MUST be inserted BEFORE the colorscheme command
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
au InsertLeave * match ExtraWhitespace /\s\+$/
" Color scheme
" mkdir -p ~/.vim/colors && cd ~/.vim/colors
" wget -O wombat256mod.vim http://www.vim.org/scripts/download_script.php?src_id=13400
set t_Co=256
color wombat256mod
" Enable syntax highlighting
" You need to reload this file for the change to apply
filetype off
filetype plugin indent on
syntax on
" Showing line numbers and length
set number " show line numbers
set tw=79 " width of document (used by gd)
set nowrap " don't automatically wrap on load
set fo-=t " don't automatically wrap text when typing
set colorcolumn=80
highlight ColorColumn ctermbg=233
" easier formatting of paragraphs
vmap Q gq
nmap Q gqap
" Useful settings
set history=700
set undolevels=700
" Real programmers don't use TABs but spaces
set tabstop=4
set softtabstop=4
set shiftwidth=4
set shiftround
set expandtab
" Make search case insensitive
set hlsearch
set incsearch
set ignorecase
set smartcase
" Disable stupid backup and swap files - they trigger too many events
" for file system watchers
set nobackup
set nowritebackup
set noswapfile
" Setup Pathogen to manage your plugins
" mkdir -p ~/.vim/autoload ~/.vim/bundle
" curl -so ~/.vim/autoload/pathogen.vim https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim
" Now you can install any plugin into a .vim/bundle/plugin-name/ folder
call pathogen#infect()
" ============================================================================
" Python IDE Setup
" ============================================================================
" Settings for vim-powerline
" cd ~/.vim/bundle
" git clone git://github.com/Lokaltog/vim-powerline.git
set laststatus=2
" Settings for ctrlp
" cd ~/.vim/bundle
" git clone https://github.com/kien/ctrlp.vim.git
let g:ctrlp_max_height = 30
set wildignore+=*.pyc
set wildignore+=*_build/*
set wildignore+=*/coverage/*
" Settings for python-mode
" Note: I'm no longer using this. Leave this commented out
" and uncomment the part about jedi-vim instead
" cd ~/.vim/bundle
" git clone https://github.com/klen/python-mode
"" map <Leader>g :call RopeGotoDefinition()<CR>
""let ropevim_enable_shortcuts = 1
""let g:pymode_rope_goto_def_newwin = "vnew"
""let g:pymode_rope_extended_complete = 1
""let g:pymode_breakpoint = 0
""let g:pymode_syntax = 1
""let g:pymode_syntax_builtin_objs = 0
""let g:pymode_syntax_builtin_funcs = 0
""map <Leader>b Oimport ipdb; ipdb.set_trace() # BREAKPOINT<C-c>
" Settings for jedi-vim
" cd ~/.vim/bundle
""git clone git://github.com/davidhalter/jedi-vim.git
let g:jedi#usages_command = "<leader>z"
let g:jedi#popup_on_dot = 0
let g:jedi#popup_select_first = 0
map <Leader>b Oimport ipdb; ipdb.set_trace() # BREAKPOINT<C-c>
" Better navigating through omnicomplete option list
" See http://stackoverflow.com/questions/2170023/how-to-map-keys-for-popup-menu-in-vim
set completeopt=longest,menuone
function! OmniPopup(action)
if pumvisible()
if a:action == 'j'
return "\<C-N>"
elseif a:action == 'k'
return "\<C-P>"
endif
endif
return a:action
endfunction
inoremap <silent><C-j> <C-R>=OmniPopup('j')<CR>
inoremap <silent><C-k> <C-R>=OmniPopup('k')<CR>
" Python folding
" mkdir -p ~/.vim/ftplugin
" wget -O ~/.vim/ftplugin/python_editing.vim http://www.vim.org/scripts/download_script.php?src_id=5492
set nofoldenable
I added this to enable copy and paste things with use if F2
set pastetoggle=<F2>
set clipboard=unnamed
I want to enable that feature. Please help
Thank's
Normally, Vim yanks (copies) to it's own internal register.
If you want to yank to a specific register, prepend your yank operation with a denotion of that register.
For example to yank a line to register x use
"xyy
To yank your visual selection to register z, use
"zy
The global clipboard is in register * or register + depending on your system
So to yank to one of these registers, replace x and z with * or +
Similarly, to put (paste) from the global clipboard, use
"*p
or
"+p
I have begun debugging my .vimrc file after migrating to windows (see related question here). In Ubuntu, I mapped the jj key combination to ESC like so
inoremap jj <Esc>
Although pressing jj does help get me out of insert mode, it tries to seek forward 10 or 15 characters (I haven't actually counted). Here are some other things that may be relevant,
; enters command mode but q; does not give me the command mode history, I have to type q:
I have mapped SHIFT + J (<S-J>) to previous buffer command (bp). It too moves the cursor left/right. Similarly for SHIFT + K (<S-K>) mapped to bn
j and k commands behave normally
It seems to be only with cases where the ENTER or ESC buttons are triggered
Here is my vimrc file in case it helps
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Swap ; and : Convenient.
nnoremap ; :
nnoremap : ;
" Create Blank Newlines and stay in Normal mode
nnoremap <silent> zj o<Esc>
nnoremap <silent> zk O<Esc>
"Make cursor move as expected with wrapped lines:
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
"Map Shift+ J to previous buffer
noremap <S-J> :bp<CR>
"Map Shift + K to next buffer
noremap <S-k> :bn<CR>
"Turn on syntax (I guess)
syntax on
" Needed for Syntax Highlighting and stuff
filetype on
filetype plugin on
syntax enable
set grepprg=grep\ -nH\ $*
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
" set viminfo='10,\"100,:20,%,n~/.viminfo
"Restore cursor position
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
" Fast saving
noremap <leader>w :w!<cr>
" Fast editing of the .vimrc
" map <leader>e :e! ~/.vimrc<cr>
" noremap <leader>e :e! c:\\Users/username/.vimrc<cr>
" When vimrc is edited, reload it
" autocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc
"These two lines display the file name at the bottom
set modeline
set ls=2
"Default for checking marks is 4 seconds, make it faster
set updatetime=100
"Persistent Undo
" set undodir=~/.vim/undodir
set undodir=c:\\Users\user\vim\undodir
set undofile
set undolevels=10000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
"Keep undo history when switching buffers
set hidden
"Don't use vi-compatibility mode
set nocompatible
"Use the smart version of backspace (jumps over tabs apparently instead of
"spaces
set backspace=2
"Use spaces instead of tabs
set expandtab
"Line Numbers
set number
"Makes unnamed clipboard accesible to X window
set clipboard=unnamedplus
"Number of spaces to use for each step of (auto)indent.
set shiftwidth=4
"This shows what you are typing as a command
set showcmd
"Not too sure what this does
set smarttab
"Indent every time you press enter
set autoindent
set smartindent
"Use C style indent instead (note this causes problems with non C code)
" set cindent
"Cursor Always in middle
"NOTE This causes problems with word wrap of long lines as they are not
"displayed correctly
set scrolloff=999
"Always display row/column info
set ruler
"make word wrap wrap words, not character
set formatoptions=l
set lbr
"Use ... when word wrapping
set showbreak=...
"enable status line always
set laststatus=2
"
" statusline
" cf the default statusline: %<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
" format markers:
" %< truncation point
" %n buffer number
" %f relative path to file
" %m modified flag [+] (modified), [-] (unmodifiable) or nothing
" %r readonly flag [RO]
" %y filetype [ruby]
" %= split point for left and right justification
" %-35. width specification
" %l current line number
" %L number of lines in buffer
" %c current column number
" %V current virtual column number (-n), if different from %c
" %P percentage through buffer
" %) end of width specification
set statusline=%f%m%r%h%w[%n]\ [F=%{&ff}][T=%Y]\ %=[LINE=%l][%p%%]
"set it up to change the status line based on mode
if version >= 700
au InsertEnter * hi StatusLine term=reverse ctermbg=4
au InsertLeave * hi StatusLine term=reverse ctermbg=2
endif
"start searching as you type
set incsearch
"Map jj to escape
inoremap jj <Esc>
"Highlight search strings
set hlsearch
" Set off the other paren
highlight MatchParen ctermbg=4
"Ignore case when searching
set ignorecase
"But remember case when capitals used
set smartcase
" Use english for spellchecking, but don't spellcheck by default
if version >= 700
set spl=en spell
set nospell
endif
"Show matching brackets when text indicator is over them
set showmatch
"How many tenths of a second to blink
"Does not seem to change anything
set mat=2
"Highlight current line
set cul
"adjust highlight color
hi CursorLine term=none cterm=none ctermbg=232
"enable 256 color
set t_Co=256
"Do not want spell checking in my commented blocks
let g:tex_comment_nospell= 1
if &t_Co == 256
" colorscheme xoria256
colorscheme desert
else
colorscheme peachpuff
endif
" Restore cursor position to where it was before
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:p:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
\ let b:doopenfold = 1 |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
\ let b:doopenfold = 2 |
\ endif |
\ exe JumpCursorOnEdit_foo |
\ endif |
\ endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
\ if exists("b:doopenfold") |
\ exe "normal zv" |
\ if(b:doopenfold > 1) |
\ exe "+".1 |
\ endif |
\ unlet b:doopenfold |
\ endif
augroup END
function! Time()
return strftime("%c", getftime(bufname("%")))
endfunction
" Font size
if has("gui_running")
if has("gui_gtk2")
set guifont=Inconsolata\ 12
elseif has("gui_macvim")
set guifont=Menlo\ Regular:h14
elseif has("gui_win32")
set guifont=Consolas:h14:cANSI
endif
endif
You have trailing whitespace in your command. (Actually a bunch of mappings have it)
Delete it.
The trailing whitespace is added to the command and moves the cursor forward equal to the number of spaces.
An easy way to do this on the whole file is to run
:%s/\s\+$//
What's the point of a comment like this one:
"Turn on syntax (I guess)
syntax on
or this one:
"Keep undo history when switching buffers
set hidden
or this one:
"Not too sure what this does
set smarttab
or this one:
"These two lines display the file name at the bottom
set modeline
set ls=2
(especially considering you enable the statusline a second time later)
Also…
"enable 256 color
set t_Co=256
if &t_Co == 256
colorscheme desert
else
colorscheme peachpuff
endif
Thanks to set t_Co=256 you will never see peachpuff.
set t_Co=256 has nothing to do in your vimrc. Set up your terminal emulator instead.
"Always display row/column info
set ruler
" statusline
set statusline=%f%m%r%h%w[%n]\ [F=%{&ff}][T=%Y]\ %=[LINE=%l][%p%%]
Your custom statusline overrides 'ruler'. Remove set ruler from your config.
set smartindent
is not "smart" at all. Remove it from your config.
"Don't use vi-compatibility mode
set nocompatible
is both wrong and useless. Remove it from your config.
"Turn on syntax (I guess)
syntax on
" Needed for Syntax Highlighting and stuff
filetype on
filetype plugin on
syntax enable
syntax on implies filetype on,
filetype plugin on implies filetype on,
you already did syntax on so there's no need to do syntax enable.
Use this instead:
filetype plugin indent on
syntax on
noremap <S-k> :bn<CR>
should be:
nnoremap K :bn<CR>
but K — keyword lookup — is rather useful so that's not a very good idea.
noremap <S-J> :bp<CR>
should be:
nnoremap J :bp<CR>
but J — join — is too useful to be remapped to anything.
let g:mapleader = ","
is useless and can be removed safely.
I'm really eager to include the following in my .vimrc file:
inoremap <Tab> <C-x><C-u>
If I set it within a buffer (via :inoremap <Tab> <C-x><C-u>) it works exactly as I'd hoped.
But, if I place it in my .vimrc, it doesn't seem to be acknowledged at all.
I've attached my .vimrc below. A few things:
Other changes to the .vimrc file are picked up, so it's not the wrong file
Have tried adding at the very bottom of the .vimrc & still doesn't work, so it's not being overwritten
Any ideas appreciated. Many thanks.
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Word complete
" :autocmd BufEnter * call DoWordComplete()
" let g:WC_min_len = 4
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
map j gj
map k gk
set showmatch " Show matching brackets
set mat=5 " Bracket blinking
set noerrorbells " No noise
" Ruby autocomplete
" Autocomplete behaviour
set completeopt=longest,menuone
open omni completion menu closing previous if open and opening new menu without changing the text
inoremap <expr> <C-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
\ '<C-x><C-o><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'
" open user completion menu closing previous if open and opening new menu without changing the text
inoremap <expr> <S-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
\ '<C-x><C-u><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
" highlight Pmenu ctermbg=238 gui=bold "improve autocomplete menu color
" Colours
highlight Pmenu ctermfg=6 ctermbg=238 guibg=grey30
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" if has("vms")
" set nobackup " do not keep a backup file, use versions instead
" else
" set backup " keep a backup file
" endif
" Set backupdir to tmp
" Do not let vim create <filename>~ backup files
set nobackup
" set nowritebackup
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" Set tab to 2 spaces
set ts=2
set shiftwidth=2
" Ignore case
set ignorecase
set smartcase
" Menu autocomplete
set wildmode=longest,list
set wildmenu
" Call pathogen
call pathogen#infect()
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" 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
" Turn syntax highlighting on (Added by John Bayne, 18/08/2012)
syntax on
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" My customisations
" No backup files
set nobackup
set nowritebackup
set noswapfile
" Whitespace identifier
:highlight ExtraWhitespace ctermbg=darkgreen guibg=lightgreen
:match ExtraWhitespace /\s\+$/
" Colour options
" color codeschool
" set guifont=Monaco:h12
" let g:NERDTreeWinPos = "right"
" set guioptions-=T " Removes top toolbar
" set guioptions-=r " Removes right hand scroll bar
" set go-=L " Removes left hand scroll bar
" autocmd User Rails let b:surround_{char2nr('-')} = "<% \r %>" " displays <% %> correctly
" :set cpoptions+=$ " puts a $ marker for the end of words/lines in cw/c$ commands
" Tab behaviour for ultisnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
inoremap <Tab> <C-x><C-u>
In this case, :scriptnames, while useful, is not the best way to see where a mapping was last set.
:verbose map <tab>
is a lot more precise.
Maybe another script is overwriting it after your .vimrc is read.
You can use :scriptnames to see what files are read on startup.