User Tools

Site Tools


linux:vim_dodger_setup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:vim_dodger_setup [2022/02/15 10:37] dodgerlinux:vim_dodger_setup [2022/12/14 10:32] (current) – [Globals] dodger
Line 9: Line 9:
 ^Tags:| | ^Tags:| |
  
-====== Simple vimrc ====== 
  
-<file vim .vimrc> +====== Advanced vimrc (2022) edition====== 
-" URL: http://vim.wikia.com/wiki/Example_vimrc + 
-" Authors: http://vim.wikia.com/wiki/Vim_on_Freenode +I have additionally [[https://git.ciberterminal.net/public/vim_setup|created a repository]] with config files :-) 
-" DescriptionA minimal, but feature rich, example .vimrc. If you are a + 
-             newbie, basing your first .vimrc on this file is a good choice. + 
-             If you're a more advanced user, building your own .vimrc based + 
-             on this file is still a good idea. +===== System Packages (not bundled) ===== 
-  + 
-"------------------------------------------------------------ +==== ubuntu ==== 
-" Features {{{1 +<code> 
-" +vim 
-" These options and commands enable some very useful features in Vim, that +vim-addon-manager 
-" no user should have to live without. +vim-airline 
-  +vim-airline-themes 
-" Set 'nocompatible' to ward off unexpected things that your distro might +vim-common 
-" have made, as well as sanely reset options when re-sourcing .vimrc +vim-fugitive 
-set nocompatible +vim-nox 
-  +vim-puppet 
-" Attempt to determine the type of a file based on its name and possibly its +vim-python-jedi 
-" contents. Use this to allow intelligent auto-indenting for each filetype, +vim-runtime 
-" and for plugins that are filetype specific. +vim-syntastic 
-filetype indent plugin on +vim-syntax-docker 
-  +vim-tiny 
-" Enable syntax highlighting +vim-youcompleteme 
-syntax on +</code
-  +One line: 
-  +<code bash
-"------------------------------------------------------------ +apt install vim vim-addon-manager vim-airline vim-airline-themes vim-common vim-fugitive vim-nox vim-puppet vim-python-jedi vim-runtime vim-syntastic vim-syntax-docker vim-tiny vim-youcompleteme 
-" Must have options {{{1 +</code> 
-+ 
-" These are highly recommended options. + 
-  +===== Globals ===== 
-" Vim with default settings does not allow easy switching between multiple files +This is the initial vimrc file
-" in the same editor window. Users can use multiple split windows or multiple +<file vim ~/.vimrc
-" tab pages to edit multiple files, but it is still best to enable an option to +############################################## 
-" allow easier switching between files. +GLOBAL CONFIG 
-+############################################## 
-" One such option is the 'hidden' option, which allows you to re-use the same +set encoding=utf-8 
-" window and switch from an unsaved buffer without saving it first. Also allows +set nocompatible      We're running Vim, not Vi! 
-" you to keep an undo history for multiple files when re-using the same window + 
-" in this way. Note that using persistent undo also lets you undo in multiple +map leader with , to start combos 
-" files even in the same window, but is less efficient and is actually designed +let mapleader = "," 
-" for keeping undo history after closing Vim entirely. Vim will complain if you +
-" try to quit without saving, and swap files will keep you safe if your computer +
-" crashes. +
-set hidden +
-  +
-" Note that not everyone likes working this way (with the hidden option). +
-" Alternatives include using tabs or split windows instead of re-using the same +
-" window as mentioned above, and/or either of the following options: +
-" set confirm +
-" set autowriteall +
-  +
-" Better command-line completion +
-set wildmenu +
-  +
-" Show partial commands in the last line of the screen +
-set showcmd +
-  +
-" Highlight searches (use <C-L> to temporarily turn off highlighting; see the +
-" mapping of <C-Lbelow) +
-set hlsearch +
-  +
-" Modelines have historically been a source of security vulnerabilities. As +
-" such, it may be a good idea to disable them and use the securemodelines +
-" script, <http://www.vim.org/scripts/script.php?script_id=1876>. +
-" set nomodeline +
-  +
-  +
-"------------------------------------------------------------ +
-" Usability options {{{1 +
-" +
-" These are options that users frequently set in their .vimrc. Some of them +
-" change Vim's behaviour in ways which deviate from the true Vi way, but +
-" which are considered to add usability. Which, if any, of these options to +
-" use is very much a personal preference, but they are harmless. +
-  +
-" Use case insensitive search, except when using capital letters +
-set ignorecase +
-set smartcase +
-  +
-" Allow backspacing over autoindent, line breaks and start of insert action +
-set backspace=indent,eol,start +
-  +
-" When opening a new line and no filetype-specific indenting is enabled, keep +
-the same indent as the line you're currently on. Useful for READMEs, etc+
-set autoindent +
-  +
-" Stop certain movements from always going to the first character of a line. +
-" While this behaviour deviates from that of Vi, it does what most users +
-" coming from other editors would expect. +
-set nostartofline +
-  +
-" Display the cursor position on the last line of the screen or in the status +
-" line of a window +
-set ruler +
-  +
-" Always display the status line, even if only one window is displayed +
-set laststatus=2 +
-  +
-" Instead of failing a command because of unsaved changes, instead raise a +
-" dialogue asking if you wish to save changed files. +
-set confirm +
-  +
-" Use visual bell instead of beeping when doing something wrong +
-set visualbell +
-  +
-" And reset the terminal code for the visual bell. If visualbell is set, and +
-" this line is also included, vim will neither flash nor beepIf visualbell +
-" is unset, this does nothing. +
-set t_vb= +
-  +
-" Enable use of the mouse for all modes +
-" set mouse=a +
-  +
-" Set the command window height to 2 lines, to avoid many cases of having to +
-" "press <Enterto continue" +
-set cmdheight=2 +
-  +
-Display line numbers on the left +
-set number +
-  +
-Quickly time out on keycodes, but never time out on mappings +
-set notimeout ttimeout ttimeoutlen=200 +
-  +
-Use <F11> to toggle between 'paste' and 'nopaste' +
-set pastetoggle=<F11> +
-  +
-  +
-"------------------------------------------------------------ +
-" Indentation options {{{1 +
-+
-" Indentation settings according to personal preference. +
-  +
-" Indentation settings for using 4 spaces instead of tabs. +
-" Do not change 'tabstop' from its default value of with this setup. +
-set shiftwidth=4 +
-set softtabstop=4 +
-set expandtab +
-  +
-Indentation settings for using hard tabs for indent. Display tabs as +
-" four characters wide. +
-"set shiftwidth=4 +
-"set tabstop=+
-  +
-  +
-"------------------------------------------------------------ +
-" Mappings {{{1 +
-+
-" Useful mappings +
-  +
-" Map Y to act like D and Ci.e. to yank until EOL, rather than act as yy, +
-which is the default +
-map Y y$ +
-  +
-" Map <C-L> (redraw screen) to also turn off search highlighting until the +
-" next search +
-nnoremap <C-L> :nohl<CR><C-L> +
-  +
-"------------------------------------------------------------+
 </file> </file>
  
- +I'm remaping the leader key for convenience...
-====== Advanced vimrc (2022) edition======+
  
 ===== vim-plug ===== ===== vim-plug =====
Line 256: Line 137:
  
 That will install all the above plugins: That will install all the above plugins:
-  * 'junegunn/vim-easy-align' +  * ''junegunn/vim-easy-align'
-  * 'https://github.com/junegunn/vim-github-dashboard.git' +  * ''https://github.com/junegunn/vim-github-dashboard.git'
-  * 'SirVer/ultisnips' +  * ''SirVer/ultisnips'
-  * 'scrooloose/nerdtree', +  * ''scrooloose/nerdtree'', 
-  * 'tpope/vim-fireplace', +  * ''tpope/vim-fireplace'', 
-  * 'rdnetto/YCM-Generator', +  * ''rdnetto/YCM-Generator'', 
-  * 'fatih/vim-go', +  * ''fatih/vim-go'', 
-  * 'nsf/gocode', +  * ''nsf/gocode'', 
-  * 'junegunn/fzf', +  * ''junegunn/fzf'', 
-  * 'tpope/vim-sensible' +  * ''tpope/vim-sensible'
-  * 'junegunn/seoul256.vim' +  * ''junegunn/seoul256.vim'
-  * 'vim-syntastic/syntastic' +  * ''vim-syntastic/syntastic'
-  * 'mbbill/undotree'+  * ''mbbill/undotree''
  
 +
 +
 +
 +===== Additional syntax/configs =====
 +==== Tagbar ====
 +Used for function/classes navigation [https://preservim.github.io/tagbar/|link].
 +
 +<code bash>
 +cd ~/.vim/bundle
 +git clone https://github.com/preservim/tagbar.git
 +</code>
 +And add to ''~/.vimrc'':
 +<code vim>
 +" tagbar 
 +nmap <F8> :TagbarToggle<CR>
 +
 +</code>
 +
 +
 +
 +==== terraform syntax ====
 +From [[https://github.com/hashivim/vim-terraform]] using ''patogen'':
 +<code bash>
 +git clone https://github.com/hashivim/vim-terraform.git ~/.vim/bundle/vim-terraform
 +</code>
 +
 +==== Puppet syntax ====
 +From [[https://github.com/rodjek/vim-puppet]] using ''pathogen'' :
 +<code bash>
 +git clone https://github.com/rodjek/vim-puppet.git ~/.vim/bundle/vim-puppet
 +</code>
  
  
Line 351: Line 263:
  
 <file vim ~/.vim/pluginconf/undotree.vim> <file vim ~/.vim/pluginconf/undotree.vim>
 +" https://github.com/mbbill/undotree/blob/master/plugin/undotree.vim
 +"=================================================
 +"Options:
 +
 +" Window layout
 +" style 1
 +" +----------+------------------------+
 +" |          |                        |
 +" |          |                        |
 +" | undotree |                        |
 +" |          |                        |
 +" |          |                        |
 +" +----------+                        |
 +" |          |                        |
 +" |   diff                          |
 +" |          |                        |
 +" +----------+------------------------+
 +" Style 2
 +" +----------+------------------------+
 +" |          |                        |
 +" |          |                        |
 +" | undotree |                        |
 +" |          |                        |
 +" |          |                        |
 +" +----------+------------------------+
 +" |                                   |
 +" |   diff                            |
 +" |                                   |
 +" +-----------------------------------+
 +" Style 3
 +" +------------------------+----------+
 +" |                        |          |
 +" |                        |          |
 +" |                        | undotree |
 +" |                        |          |
 +" |                        |          |
 +" |                        +----------+
 +" |                        |          |
 +" |                        |   diff   |
 +" |                        |          |
 +" +------------------------+----------+
 +" Style 4
 +" +-----------------------++----------+
 +" |                        |          |
 +" |                        |          |
 +" |                        | undotree |
 +" |                        |          |
 +" |                        |          |
 +" +------------------------+----------+
 +" |                                   |
 +" |                            diff   |
 +" |                                   |
 +" +-----------------------------------+
 +if !exists('g:undotree_WindowLayout')
 +    let g:undotree_WindowLayout = 2
 +endif
 +
 if has("persistent_undo") if has("persistent_undo")
    let target_path = expand('~/.vim/undodir')    let target_path = expand('~/.vim/undodir')
Line 367: Line 336:
 </file> </file>
  
 +
 +**Disabled, using FZF**
 <file vim ~/.vim/pluginconf/nerdtree.vim> <file vim ~/.vim/pluginconf/nerdtree.vim>
 nnoremap <leader>n :NERDTreeFocus<CR> nnoremap <leader>n :NERDTreeFocus<CR>
Line 372: Line 343:
 nnoremap <C-t> :NERDTreeToggle<CR> nnoremap <C-t> :NERDTreeToggle<CR>
 nnoremap <C-f> :NERDTreeFind<CR> nnoremap <C-f> :NERDTreeFind<CR>
 +</file>
 +
 +
 +FZF:
 +<file vim ~/.vim/pluginconf/fzf.vim>
 +" https://github.com/junegunn/fzf/blob/master/README-VIM.md
 +nnoremap <leader>f :FZF<CR>
 +let g:fzf_action = {
 +  \ 'ctrl-t': 'tab split',
 +  \ 'ctrl-x': 'split',
 +  \ 'ctrl-v': 'vsplit' }
 +</file>
 +
 +
 +===== Cheatsheet generated =====
 +
 +In my config:
 +  * ''leader'' is '',''
 +  * ''<C>'' is control key
 +
 +
 +^ ##############'''Shortcut'''############## ^ ##############''command executed''############## ^ ------------------------------------------------------------------ ^
 +|''<leader>f'' | '':FZF<CR>'' | Open ''fzf'' |
 +| inside fzf -> ''<C-t> '' | ''g:fzf_action 'tab split'<CR>'' | Tab split selected file |
 +| inside fzf -> ''<C-x> '' | ''g:fzf_action 'split'<CR>'' | split selected file |
 +| inside fzf -> ''<C-v> '' | ''g:fzf_action 'vsplit'<CR>'' | vsplit selected file |
 +|''<leader>u'' | '':UndotreeToggle<CR>'' | Toggle Undotree pannel |
 +|''<leader>b'' | '':BuffergatorOpen<CR>'' | Open Buffergator pannel |
 +| ''[count]<leader>cc'' | '':NERDCommenterComment'' | Comment out the current line or text selected in visual mode. | 
 +| ''[count]<leader>cn'' | '':NERDCommenterNested'' | Same as cc but forces nesting. | 
 +| ''[count]<leader>c<space>'' | '':NERDCommenterToggle'' | Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa. | 
 +| ''[count]<leader>cm'' | '':NERDCommenterMinimal'' | Comments the given lines using only one set of multipart delimiters. | 
 +| ''[count]<leader>ci'' | '':NERDCommenterInvert'' | Toggles the comment state of the selected line(s) individually. | 
 +| ''[count]<leader>cs'' | '':NERDCommenterSexy'' | Comments out the selected lines with a pretty block formatted layout. | 
 +| ''[count]<leader>cy'' | '':NERDCommenterYank'' | Same as cc except that the commented line(s) are yanked first. | 
 +| ''<leader>c$'' | '':NERDCommenterToEOL'' | Comments the current line from the cursor to the end of line. | 
 +| ''<leader>cA'' | '':NERDCommenterAppend'' | Adds comment delimiters to the end of line and goes into insert mode between them. | 
 +| ''<leader>ca'' | '':NERDCommenterAltDelims'' | Switches to the alternative set of delimiters. | 
 +| ''[count]<leader>cl'' | '':NERDCommenterAlignLeft'' | Same as '':NERDCommenterComment'' except that the delimiters are aligned down the left side (<leader>cl) or both sides (<leader>cb). | 
 +| ''[count]<leader>cb'' | '':NERDCommenterAlignBoth'' | Same as '':NERDCommenterComment'' except that the delimiters are aligned down the left side (<leader>cl) or both sides (<leader>cb). | 
 +| ''[count]<leader>cu'' | '':NERDCommenterUncomment''| Uncomments the selected line(s). 
 +
 +
 + 
 +====== Simple vimrc ======
 +
 +<file vim .vimrc>
 +" URL: http://vim.wikia.com/wiki/Example_vimrc
 +" Authors: http://vim.wikia.com/wiki/Vim_on_Freenode
 +" Description: A minimal, but feature rich, example .vimrc. If you are a
 +             newbie, basing your first .vimrc on this file is a good choice.
 +             If you're a more advanced user, building your own .vimrc based
 +             on this file is still a good idea.
 + 
 +"------------------------------------------------------------
 +" Features {{{1
 +"
 +" These options and commands enable some very useful features in Vim, that
 +" no user should have to live without.
 + 
 +" Set 'nocompatible' to ward off unexpected things that your distro might
 +" have made, as well as sanely reset options when re-sourcing .vimrc
 +set nocompatible
 + 
 +" Attempt to determine the type of a file based on its name and possibly its
 +" contents. Use this to allow intelligent auto-indenting for each filetype,
 +" and for plugins that are filetype specific.
 +filetype indent plugin on
 + 
 +" Enable syntax highlighting
 +syntax on
 + 
 + 
 +"------------------------------------------------------------
 +" Must have options {{{1
 +"
 +" These are highly recommended options.
 + 
 +" Vim with default settings does not allow easy switching between multiple files
 +" in the same editor window. Users can use multiple split windows or multiple
 +" tab pages to edit multiple files, but it is still best to enable an option to
 +" allow easier switching between files.
 +"
 +" One such option is the 'hidden' option, which allows you to re-use the same
 +" window and switch from an unsaved buffer without saving it first. Also allows
 +" you to keep an undo history for multiple files when re-using the same window
 +" in this way. Note that using persistent undo also lets you undo in multiple
 +" files even in the same window, but is less efficient and is actually designed
 +" for keeping undo history after closing Vim entirely. Vim will complain if you
 +" try to quit without saving, and swap files will keep you safe if your computer
 +" crashes.
 +set hidden
 + 
 +" Note that not everyone likes working this way (with the hidden option).
 +" Alternatives include using tabs or split windows instead of re-using the same
 +" window as mentioned above, and/or either of the following options:
 +" set confirm
 +" set autowriteall
 + 
 +" Better command-line completion
 +set wildmenu
 + 
 +" Show partial commands in the last line of the screen
 +set showcmd
 + 
 +" Highlight searches (use <C-L> to temporarily turn off highlighting; see the
 +" mapping of <C-L> below)
 +set hlsearch
 + 
 +" Modelines have historically been a source of security vulnerabilities. As
 +" such, it may be a good idea to disable them and use the securemodelines
 +" script, <http://www.vim.org/scripts/script.php?script_id=1876>.
 +" set nomodeline
 + 
 + 
 +"------------------------------------------------------------
 +" Usability options {{{1
 +"
 +" These are options that users frequently set in their .vimrc. Some of them
 +" change Vim's behaviour in ways which deviate from the true Vi way, but
 +" which are considered to add usability. Which, if any, of these options to
 +" use is very much a personal preference, but they are harmless.
 + 
 +" Use case insensitive search, except when using capital letters
 +set ignorecase
 +set smartcase
 + 
 +" Allow backspacing over autoindent, line breaks and start of insert action
 +set backspace=indent,eol,start
 + 
 +" When opening a new line and no filetype-specific indenting is enabled, keep
 +" the same indent as the line you're currently on. Useful for READMEs, etc.
 +set autoindent
 + 
 +" Stop certain movements from always going to the first character of a line.
 +" While this behaviour deviates from that of Vi, it does what most users
 +" coming from other editors would expect.
 +set nostartofline
 + 
 +" Display the cursor position on the last line of the screen or in the status
 +" line of a window
 +set ruler
 + 
 +" Always display the status line, even if only one window is displayed
 +set laststatus=2
 + 
 +" Instead of failing a command because of unsaved changes, instead raise a
 +" dialogue asking if you wish to save changed files.
 +set confirm
 + 
 +" Use visual bell instead of beeping when doing something wrong
 +set visualbell
 + 
 +" And reset the terminal code for the visual bell. If visualbell is set, and
 +" this line is also included, vim will neither flash nor beep. If visualbell
 +" is unset, this does nothing.
 +set t_vb=
 + 
 +" Enable use of the mouse for all modes
 +" set mouse=a
 + 
 +" Set the command window height to 2 lines, to avoid many cases of having to
 +" "press <Enter> to continue"
 +set cmdheight=2
 + 
 +" Display line numbers on the left
 +set number
 + 
 +" Quickly time out on keycodes, but never time out on mappings
 +set notimeout ttimeout ttimeoutlen=200
 + 
 +" Use <F11> to toggle between 'paste' and 'nopaste'
 +set pastetoggle=<F11>
 + 
 + 
 +"------------------------------------------------------------
 +" Indentation options {{{1
 +"
 +" Indentation settings according to personal preference.
 + 
 +" Indentation settings for using 4 spaces instead of tabs.
 +" Do not change 'tabstop' from its default value of 8 with this setup.
 +set shiftwidth=4
 +set softtabstop=4
 +set expandtab
 + 
 +" Indentation settings for using hard tabs for indent. Display tabs as
 +" four characters wide.
 +"set shiftwidth=4
 +"set tabstop=4
 + 
 + 
 +"------------------------------------------------------------
 +" Mappings {{{1
 +"
 +" Useful mappings
 + 
 +" Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy,
 +" which is the default
 +map Y y$
 + 
 +" Map <C-L> (redraw screen) to also turn off search highlighting until the
 +" next search
 +nnoremap <C-L> :nohl<CR><C-L>
 + 
 +"------------------------------------------------------------
 </file> </file>
  
linux/vim_dodger_setup.1644921434.txt.gz · Last modified: 2022/02/15 10:37 by dodger