I am new to vim and trying to use NERDTree. Well, I think I succeeded to install it but every time I open NERDTree, it opens at the right part of the window as shown below. I want it to open at the left as default but I don't know how. How can I open NERDTree at the left side of the window by default?
I tried to put let g:NERDTreeWinPos = "LEFT" or let g:NERDTreeWinPos = "left" in vimrc file but it didn't work.
For more details my .vimrc code looks like this
I use ultimate vim.'
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
let g:NERDTreeWinPos = "LEFT"
set runtimepath+=~/.vim_runtime
set showcmd
set number
source ~/.vim_runtime/vimrcs/basic.vim
source ~/.vim_runtime/vimrcs/filetypes.vim
source ~/.vim_runtime/vimrcs/plugins_config.vim
source ~/.vim_runtime/vimrcs/extended.vim
try
source ~/.vim_runtime/my_configs.vim
catch
endtry
In case this has not been answered, access the ~/.vim_runtime/vimrcs/plugins_config.vim file and change the NERDTree position in that file.
Related
I am trying to get Julia to have syntax highlighting in Vim. Unfortunately, at the moment, I there is no syntax highlighting (here is a small snippet of my code so you can see what it currently looks like). I tried installing julia-vim and putting it in the .vimrc file and installing it, but it doesn't actually change the highlighting. Below is the .vimrc file:
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own
plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or
just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append
`!` to auto-approve removal
"
Plugin 'JuliaEditorSupport/julia-vim'
"
"
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
I'm also note sure how to fix it after reading the julia-vim documentation. Am I doing anything incorrectly, or is there another way to add some syntax highlighting to Julia?
I have seen from one of the answers to this question asked by #Thomas that it might be how I have set up my terminal, but I'd prefer to keep the terminal with the present color scheme if possible. See here for my current settings.
EDIT: Thanks to #axwr, I was able to get some syntax highlighting by putting
syntax on
at the end of the .vimrc file and then running
:so %
while editing the .vimrc file. However, as you can see here, the color coding seems to be less than ideal. Only certain packages come up as yellow, the majority is still green, and random things (usually numbers) come up as purple. Is this how julia-vim colors things, or am I doing something wrong?
Okay, so.
There are two steps to syntax highlighting in Vim; actually turning it on, and, having the ability to highlight the specific language you want to work in. For most languages vim can do this by default, however some languages, like Julia, require a little help. In this case you have done step two by using vundle to install a Julia plugin.
To acheive step one, you just need the line: syntax on in your vimrc file.
A minimal example vimrc for you, might look like:
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'JuliaEditorSupport/julia-vim'
call vundle#end()
set nocompatible
set backspace=indent,eol,start
set number
set hidden
syntax on
filetype plugin indent on
Given the above settings, and a terminal that has the "solarised" colorscheme, a julia file looks like:
Here is the little fizzbuzz julia snippet so you can compare against your highlighting:
for i in 1:100
if i % 15 == 0
println("FizzBuzz")
elseif i % 3 == 0
println("Fizz")
elseif i % 5 == 0
println("Buzz")
else
println(i)
end
end
So, Step by step:
Add syntax on to your .vimrc
Add filetype plugin indent on to your .vimrc
Install the relevant plugin
Source your .vimrc or close vim.
open a file with the correct extension, i.e: test.jl
This is my .vimrc located under $HOME/.vimrc. I've installed Vundle.
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'dracula/dracula-theme'
call vundle#end() " required
filetype plugin indent on " required
" Put your non-Plugin stuff after this line
I'm able to execute :PluginInstall successfully installing dracula-theme. Unfortunately the theme is not applied and the style remains unchanged? Any clues?
Adding Plugin 'dracula/dracula-theme' to your vimrc and using :PluginInstall make the colorscheme available to Vim but it doesn't say to Vim to use it.
As #dNitro said in the comment you have to use the command colorscheme to set the desired colorscheme. Thus you need to add a line colorscheme dracula to your vimrc after the line " Put your non-Plugin stuff after this line.
I'm using Vim with Syntastic and JSHint, and there are a few bits of glitchy behavior that I'd like to fix.
Whenever I modify the last character on a line of text and save (:w), I momentarily see "^M" flash after the text before (sometimes) vanishing. Sometimes it sticks around and I have to manually delete it. What's the deal with this and how do I prevent it?
When there is an error in the quickfix view, how do I toggle focus between the quickfix view and the Vim editor window?
Vim crashes maybe once per minute, and I haven't the slightest clue as to why, but it's extremely annoying. The error typically reads "Vim: Caught deadly signal ABRT Vim: Finished. [1]6099 abort vi gulpfile.js" How do I prevent this?
Here is my .vimrc file:
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
"Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
"Plugin 'user/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" React.js/JSX syntax highlighting
"Plugin 'mxw/vim-jsx'
"
"JSHint
Plugin 'wookiehangover/jshint.vim'
"Syntastic
Plugin 'scrooloose/syntastic'
"Syntastic configuration
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_html_tidy_exec = 'tidy5'
let g:syntastic_javascript_checkers = ['jshint']
let g:JSHintHighlightErrorLine = 0
syntax on
set t_Co=256
set ai
set shiftwidth=4
set tabstop=4
set number
"colorscheme monokai
colorscheme skittles_berry
Thanks for any help you can provide.
I have no idea where your ^M issue and your crashing issue come from but you don't need such a huge plugin for such a simple task.
Create ~/.vim/after/ftplugin/javascript.vim if it doesn't exist and paste the lines below:
errorformat for jshint
setlocal errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m,%-G%.%#
tell Vim to use jshint for the :make command
setlocal makeprg=jshint
add an autocommand to run :make on the current file upon write, the | silent wincmd p at the end switches the focus back to the editing window once the quickfix window is opened
autocmd! BufWritePost <buffer> silent make % | silent redraw! | silent wincmd p
I've never experienced a single crash with that simple setup, or that ^M issue.
With that in place you should get something like that after :w:
To move the focus from/to the quickfix window, use <C-w>p.
To jump to the previous/next error without using the quickfix window, use :cprevious/:cnext.
Reference:
:help 'errorformat'
:help 'makeprg'
:help autocmd
:help bufwritepost
:help :silent
:help :redraw
:help :wincmd
:help quickfix
Also, check out this great post: The Power of Vim
I used Vundle to install editorconfig-vim plugin. It loads correctly and is listed in :scriptnames. But when I create a new file, say, x.js, indentation settings aren't picked from ~/.editorconfig file (although, no .editorconfig in CWD), and I have 2-space indentation instead of 4-space as I defined in my ~/.editorconfig.
What do I do wrong? Should I invoke a certain command in ~/.vimrc to make EditorConfig config work?
My ~/.editorconfig:
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
[{package.json,.travis.yml,Gruntfile.js,gulpfile.js,webpack.config.js}]
indent_style = space
indent_size = 2
And my ~/.vimrc config:
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tomasr/molokai'
Plugin 'moll/vim-node'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'pangloss/vim-javascript'
Plugin 'editorconfig/editorconfig-vim'
call vundle#end() " required
filetype plugin indent on " required
" set tw=80
" set wrap linebreak nolist
let g:jsx_ext_required = 0 " Allow JSX in normal JS files
let g:syntastic_javascript_checkers = ['eslint']
let g:EditorConfig_core_mode = 'external_command'
syntax on
set number
set ruler
colorscheme molokai
You may want to use :verbose set tabstop? to check which plugin set it for you.
If it doesn't say Last set from ..., it uses the default option.
And then, editorconfig doesn't have the corresponding settings, and you may want to check which .editorconfig is used.
It is possible that another plugin is overriding the editorconfig plugin.
This happened to me. I had forgotten about installing https://github.com/Raimondi/YAIFA (Yet Another Indent Finder, Almost). I probably would have found the problem sooner in my case, if the plugin functionality was easier to parse from its name.
It helped for me in init.lua to set:
vim.cmd('filetype plugin on')
vim.cmd('filetype indent off')
Also :verbose set autoindent? gives the actual setting value and the place from where it was loaded. Filetype settings is loaded after global settings. After disabling filetype indentation my editorconfig started to work the way i expected it to work. You can also disable all filetype options by filetype off
I installed YouCompleteMe using vundle.
Then installed all plugins and installed YCM using
./install.sh --clang-completer
This is how my vimrc looks:
syntax on
set expandtab
set cindent
set tabstop=4
retab
set shiftwidth=4
set hlsearch
set paste
set ic
set number
colorscheme molokai
set t_Co=256
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-repeat'
Plugin 'kien/ctrlp.vim'
Plugin 'sjl/gundo.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/syntastic'
Plugin 'Valloric/ListToggle'
call vundle#end() " required
filetype plugin indent on
"options for syntastic"
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_python_checkers=['pep8', 'pylint', 'python']
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_error_symbol = "X"
let g:syntastic_style_error_symbol = ">"
let g:syntastic_warning_symbol = "!"
let g:syntastic_style_warning_symbol = ">"
let g:syntastic_echo_current_error=1
let g:syntastic_enable_balloons = 1
let g:syntastic_auto_jump=1
"Gundo options"
nnoremap <F5> :GundoToggle<CR>
"CtrlP options"
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
"Powerline stuff"
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup
set laststatus=2
YCM works but I can't switch between the suggestions using TAB, only using Down and Up arrows and accepting with Enter.
Why is happening this? Is another program using the TAB key?
thanks a lot for the help
By configuring set paste, you're effectively disabling all mappings and abbreviations.
You only need that set when you actually paste text in terminal Vim! It's best to bind this to a key. As mappings cannot be used when the option is set, Vim provides a special option for this:
:set pastetoggle=<F10>
Further commentary
As the ~/.vimrc is sourced at the beginning of Vim startup (when files passed to it haven't yet been loaded), the retab is ineffective; just drop it. If you really want automatic reindenting for opened files, you'd have to employ an :autocmd BufRead * retab for that, but I'd advise against that.
The problem was due to the "set paste" line in my .vimrc
so, I removed it, and when I want to paste large blocks of code in vim, I just write :set paste to enable it or :set nopaste to disable it. This toggle can be also mapped to f10 or any key.