aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Christian Pohle2016-10-18 13:54:12 +0200
committerMax Christian Pohle2016-10-18 13:54:12 +0200
commit87271db105e429a402b8934259b2390d55ac7481 (patch)
tree077fbbbfdf294d7f18e1c8cf2d18d04aafc4c2bb
parent4b53f1d6d472c0a621d29d194e43c72e54d23ec3 (diff)
downloadvim-karlmarks-87271db105e429a402b8934259b2390d55ac7481.tar.bz2
vim-karlmarks-87271db105e429a402b8934259b2390d55ac7481.zip
<leader><leader> opens, focusses & closes NERDTree
Additionally reordered many settings to make the file more readable.
-rw-r--r--doc/shortcuts.txt1
-rw-r--r--vimrc123
2 files changed, 78 insertions, 46 deletions
diff --git a/doc/shortcuts.txt b/doc/shortcuts.txt
index 540f086..daf9003 100644
--- a/doc/shortcuts.txt
+++ b/doc/shortcuts.txt
@@ -9,6 +9,7 @@ gf = open file under cursor
9<C-w>gf = open file under cursor in a tab 9<C-w>gf = open file under cursor in a tab
10<C-w>] = jump to the tag under the cursor in a new window 10<C-w>] = jump to the tag under the cursor in a new window
11<C-t> = jump back from where that ^ brought you 11<C-t> = jump back from where that ^ brought you
12K = keyword lookup for the word under the cursor (see :help kp)
12 13
13 14
14 15
diff --git a/vimrc b/vimrc
index 2af99e3..f9569e3 100644
--- a/vimrc
+++ b/vimrc
@@ -5,8 +5,6 @@ Plug 'tpope/vim-sensible' | " a sane and modern defa
5Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with ' 5Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with '
6Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin 6Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin
7Plug 'mhinz/vim-signify' | " show changes in the clutter bar 7Plug 'mhinz/vim-signify' | " show changes in the clutter bar
8" Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values)
9" Plug 'tpope/vim-repeat' | " lets . (dot) repeat plugin macros as well, specifically vim-surround
10 8
11 9
12" Colorschemes: ======================================. 10" Colorschemes: ======================================.
@@ -16,10 +14,26 @@ map <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>.
16 14
17" NERDTree: ==========================================. 15" NERDTree: ==========================================.
18Plug 'scrooloose/nerdtree' | " replace NetRW, which is kind of buggy 16Plug 'scrooloose/nerdtree' | " replace NetRW, which is kind of buggy
19map <leader><leader> :NERDTreeToggle<CR>
20set winwidth=30 " keep NERDTreeWindow at least this size 17set winwidth=30 " keep NERDTreeWindow at least this size
21set winminwidth=30 " (and all other windows, so TODO: watch out) 18set winminwidth=30 " (and all other windows, so TODO: watch out)
22 19
20" open or focus the NERDTree with this key binding and close it if it is the active buffer...
21nnoremap <expr>
22 \ <leader><leader>
23 \ !exists("b:NERDTree") ? ':NERDTreeFocus<CR>' : ':NERDTreeClose<CR>'
24
25" close NERDTree if it is the last remaining window (taken from the official documentation)
26autocmd bufenter *
27 \ if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
28
29" if NERDTree has the focus, pressing <Tab> should jump to the next window, but if the file
30" buffer is selected <Tab> should select the next buffer (:bn). That is archived by :h map-expr
31nnoremap <expr>
32 \ <Tab>
33 \ bufname("%")=='NERD_tree_1' ? '<C-W><C-W>' : ':bn<CR>'
34nnoremap <expr>
35 \ <S-Tab>
36 \ bufname("%")=='NERD_tree_1' ? '<C-W><C-W>' : ':bp<CR>'
23 37
24" AIRLINE: ===========================================. 38" AIRLINE: ===========================================.
25Plug 'vim-airline/vim-airline' | " beautification of the mode line 39Plug 'vim-airline/vim-airline' | " beautification of the mode line
@@ -93,20 +107,19 @@ let g:pymode_rope = 0 " https://github.com/david
93" let g:pymode_options_max_line_length = 120 107" let g:pymode_options_max_line_length = 120
94" let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301' 108" let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301'
95 109
96 110Plug 'honza/vim-snippets' " dependency of ultisnips (see below)
97Plug 'SirVer/ultisnips' " replaces loremipsum (and many more) 111Plug 'SirVer/ultisnips' " replaces loremipsum (and many more)
98Plug 'honza/vim-snippets' " dependency of ultisnips 112let g:UltiSnipsExpandTrigger = '<C-j>'| " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
99" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe. 113let g:UltiSnipsJumpForwardTrigger = '<C-j>'| " \
100"" Ultisnips 114let g:UltiSnipsJumpBackwardTrigger = '<C-k>'| " \
101let g:UltiSnipsExpandTrigger="<c-tab>" 115" let g:UltiSnipsListSnippets = '<c-s-tab>'| " YouCompleteMe includes those, so this isn't necessary
102let g:UltiSnipsListSnippets="<c-s-tab>" 116" let g:UltiSnipsEditSplit = 'vertical'
103 117
104" If you want :UltiSnipsEdit to split your window.
105let g:UltiSnipsEditSplit="vertical"
106 118
107" Disabled ===========================================. 119" Disabled ===========================================.
108" Plug 'Shougo/neocomplete.vim' | " alternative to YouCompleteMe in some cases 120" Plug 'Shougo/neocomplete.vim' | " alternative to YouCompleteMe in some cases
109" Plug 'Shougo/vimproc.vim' | " dependency for other Shougo plugins 121" Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values)
122" Plug 'tpope/vim-repeat' | " lets . (dot) repeat plugin macros as well, specifically vim-surround
110 123
111call plug#end() | " all plugins are getting loaded on this line, don't remove! 124call plug#end() | " all plugins are getting loaded on this line, don't remove!
112 125
@@ -124,7 +137,6 @@ colorscheme base16-phd
124" colorscheme base16-summerfruit-dark 137" colorscheme base16-summerfruit-dark
125" colorscheme base16-tommorow 138" colorscheme base16-tommorow
126" colorscheme base16-default-dark 139" colorscheme base16-default-dark
127" colorscheme vividchalk | " finally set which colorscheme to use
128 140
129 141
130" colorscheme customizations ========================= 142" colorscheme customizations =========================
@@ -137,60 +149,69 @@ inoremap <C-Space> <C-x><C-o>
137"inoremap <C-@> <C-Space> 149"inoremap <C-@> <C-Space>
138vnoremap < <gv| " allows deindenting a selected block and keeps selection 150vnoremap < <gv| " allows deindenting a selected block and keeps selection
139vnoremap > >gv| " allows indenting a selected block and keeps selection 151vnoremap > >gv| " allows indenting a selected block and keeps selection
140" if NERDTree has the focus, pressing <Tab> should jump to the next window, but if the file 152
141" buffer is selected <Tab> should select the next buffer (:bn). That is archived by :h map-expr 153" Bind CTRL+Backspace to vims version (CTRL+W) in " <CR> insert mode (only works with gvim)
142nnoremap <expr> <Tab> bufname("%")=='NERD_tree_1' ? '<C-W><C-W>' : ':bn<CR>' 154inoremap
143nnoremap <expr> <S-Tab> bufname("%")=='NERD_tree_1' ? '<C-W><C-W>' : ':bp<CR>' 155 \ <C-Backspace>
144inoremap <C-Backspace> <C-W>| " Bind CTRL+Backspace to vims version (CTRL+W) in insert mode 156 \ <C-W>
157
145 158
146 159
147" settings ============================================. 160" settings ============================================.
148" set shell=/bin/bash | " many scripts rely on bash, but its path varies why it is commented out here 161" set shell=/bin/bash | " many scripts rely on bash, but its path varies why it is commented out here
149set mouse=a | " also supported by vim, should be default 162" set selectmode=mouse,key,cmd | " enters vim's select mode when pressing shift-left or shift-END
150set noshowmode | " because we are using some powerline derivat 163" set keymodel=startsel,stopsel | " makes shift-left, shift-right available for selecting text
151set hidden | " allows switiching buffers even if the current buffer contains changes (displays +) 164set breakindent | " Every wrapped line will continue visually indented
165set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well)
166set complete+=d | " scan current and included files for defined name or macro
167set complete+=i | " scan current and included files for completions
168set concealcursor=nc | " limits the display of concealed text to normal and command mode
169set conceallevel=2 | " replace escaped chars by their utf-8 representation (useful for LaTeX)
152set confirm | " asks 'do you want to save?' 170set confirm | " asks 'do you want to save?'
153set t_Co=256 | " required on some ssh sessions
154set ts=2 sts=2 sw=2 expandtab | " indentation which i like (abbr: tabstop, softtabstop, shiftwidth)
155set scrolljump=5 | " how many lines get scrolled into view when cursor reaches the screens edge
156set encoding=utf-8 | " set up vim's cosole encoding (not file encoding, for which there is fileencoding=) 171set encoding=utf-8 | " set up vim's cosole encoding (not file encoding, for which there is fileencoding=)
172set hidden | " allows switiching buffers even if the current buffer contains changes (displays +)
173set hlsearch | " highlights all search matches (not as performant!)
157set ignorecase smartcase | " search with ignorecase by default, but use case sensitive search when one captical char is contained 174set ignorecase smartcase | " search with ignorecase by default, but use case sensitive search when one captical char is contained
158set ttimeoutlen=10 | " set esc key timeout in ms- 175set lazyredraw | " disables redraw during macro exectution (improves performance)
159set notimeout ttimeout | " improves performance but is known to cause problems on slow terminals
160set linebreak | " wrap long lines at char 'breakat', not inside words 176set linebreak | " wrap long lines at char 'breakat', not inside words
161set nowrap | " but do not (by default) wrap long lines around 177set mouse=a | " also supported by vim, should be default
162set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well)
163set number | " turn line numbers on/off (performance decreases when they are shown)
164set nocursorline | " turn visual cursor line off (improves performance)
165set nocursorcolumn | " turn visual cursor column off (improves performance) 178set nocursorcolumn | " turn visual cursor column off (improves performance)
166set ttyscroll=100 | " improves speed for terminal vim 179set nocursorline | " turn visual cursor line off (improves performance)
167set ttyfast | " improves speed for terminal vim
168set lazyredraw | " disables redraw during macro exectution (improves performance)
169set re=1
170set relativenumber | " displays current lines line no as zero point from where relative numbers are getting counted
171set nofoldenable | " disable code folding. I hate code folding 180set nofoldenable | " disable code folding. I hate code folding
172set spell spelllang=en,de | " enable spell checker 181set norelativenumber | " we deactivate relative numbers, but have them mentioned here so we won't forget they existed
182set noshowmode | " because we are using some powerline derivat
173set nostartofline | " when scrolling: do not move the cursor to column 1 183set nostartofline | " when scrolling: do not move the cursor to column 1
174set thesaurus+=/home/max/.vim/thesaurus/php.txt 184set notimeout ttimeout | " improves performance but is known to cause problems on slow terminals
175set hlsearch | " highlights all search matches (not as performant!) 185set nowrap | " but do not (by default) wrap long lines around
176set textwidth=100 | " line length (80 used to be default, but...) 186set number | " turn line numbers on/off (performance decreases when they are shown)
187set pumheight=8 | " Determines the maximum number of items to show in the popup menu for
188set redrawtime=400 | " The time in milliseconds for redrawing the display.
189set scrolljump=5 | " how many lines get scrolled into view when cursor reaches the screens edge
190set spell spelllang=en,de | " enable spell checker
177set splitbelow | " open new windows below the current one (i find that more intuitive) 191set splitbelow | " open new windows below the current one (i find that more intuitive)
178set norelativenumber 192set t_Co=256 | " required on some ssh sessions
193set textwidth=100 | " line length (80 used to be default, but...)
194set thesaurus+=/home/max/.vim/thesaurus/php.txt
195set ts=2 sts=2 sw=2 expandtab | " indentation which i like (abbr: tabstop, softtabstop, shiftwidth)
196set ttimeoutlen=10 | " set esc key timeout in ms-
197set ttyfast | " improves speed for terminal vim
198set ttyscroll=100 | " improves speed for terminal vim
179set writedelay=0 199set writedelay=0
180set breakindent | " Every wrapped line will continue visually indented 200set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color)
181 201
182if has("multi_byte") 202if has("multi_byte")
183 set encoding=utf-8 | " we need default utf-8 encoding to use cool chars as line break and so on (see below)
184 scriptencoding utf-8 | " tell vim that we are using utf-8 here 203 scriptencoding utf-8 | " tell vim that we are using utf-8 here
185 set showbreak+= | " symbol used in the beginning of a wrapped line 204 set encoding=utf-8 | " we need default utf-8 encoding to use cool chars as line break and so on (see below)
186 set listchars=eol:↲ | " symbols used when using :set list (which displays non-printable chars) 205 set listchars=eol:↲ | " symbols used when using :set list (which displays non-printable chars)
187 set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars)
188 set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars)
189 set listchars+=extends:» | " symbols used when using :set list (which displays non-printable chars) 206 set listchars+=extends:» | " symbols used when using :set list (which displays non-printable chars)
207 set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars)
190 set listchars+=tab:▸\ | " symbols used when using :set list (which displays non-printable chars) 208 set listchars+=tab:▸\ | " symbols used when using :set list (which displays non-printable chars)
209 set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars)
210 set showbreak+=› | " symbol used in the beginning of a wrapped line
191end 211end
192 212
193if has("gui_running") 213if has("gui_running")
214 set toolbar+=text
194 set guioptions+=eig 215 set guioptions+=eig
195 set guioptions-=T | " toolbar 216 set guioptions-=T | " toolbar
196 set guioptions+=c | " use console dialogs instead of popups 217 set guioptions+=c | " use console dialogs instead of popups
@@ -205,7 +226,7 @@ if bufname('%') == ''
205 set bufhidden=wipe 226 set bufhidden=wipe
206endif 227endif
207 228
208noautocmd 229" noautocmd
209 230
210if has("autocmd") 231if has("autocmd")
211 set modeline | " set variables specific to a file, like indentation by adding a comment 232 set modeline | " set variables specific to a file, like indentation by adding a comment
@@ -251,6 +272,16 @@ if has("autocmd")
251 " highlight ColorColumn guibg=#005f87 272 " highlight ColorColumn guibg=#005f87
252 " highlight ColorColumn guibg=#F0F0E0 273 " highlight ColorColumn guibg=#F0F0E0
253 augroup END " } 274 augroup END " }
275
276
277 " hitting K over a keyword shows a help in a buffer.
278 " Here we define the commands used to look those keywords up
279 " as per file type...
280 augroup keyword_lookups
281 autocmd FileType python setlocal keywordprg=pydoc
282 autocmd FileType vim setlocal keywordprg=:help |.
283 augroup END
284
254 "set omnifunc=syntaxcomplete#Complete 285 "set omnifunc=syntaxcomplete#Complete
255 " au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main 286 " au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main
256 " Enable omni completion. 287 " Enable omni completion.
..