Vim swap file issue











up vote
7
down vote

favorite












In a project, I encounter many errors like this:



E303: Unable to open swap file for "file", recovery impossible


If I execute ls -la |grep vim, I see



-rw-r--r--   1 jeremie jeremie     0 Jan 12 23:58 .ideavimrc
drwxrwxr-x 5 jeremie jeremie 4096 Feb 14 10:00 .vim
-rw------- 1 jeremie jeremie 18887 Feb 16 10:25 .viminfo
-rw-r--r-- 1 jeremie jeremie 9084 Feb 16 10:19 .vimrc
-rw-r--r-- 1 jeremie jeremie 20480 Jan 18 15:17 .vimrc.swn
-rw-r--r-- 1 jeremie jeremie 16384 Jan 15 17:12 .vimrc.swo


Is there a missing file? If so, how would I add this file?



My .vimrc file:



"ycmd debug for YouCompleteMe
let g:ycm_keep_logfiles = 0
let g:ycm_server_python_interpreter = ''

"Auto-Save
let g:auto_save = 1

"Seach words in Vim
set mouse=a

"gitgutter
let g:gitgutter_max_signs = 500 " default value
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk

"Keybinding Tagbar
nnoremap <F8> :TagbarToggle<CR>

"Automatically displays all buffers when there's only one tab open
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'

"Populate the g:airline-symbols dictionary with the powerline symbols
let g:airline_powerline_fonts = 1

" Auto-reload the configuration
augroup myvimrchooks
au!
autocmd bufwritepost .vimrc source ~/.vimrc
augroup END

:set modifiable

nnoremap <F4> :NERDTreeToggle<CR>

set directory=~/.vim/tmp

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif


" Ctrl-j/k deletes blank line below/above, and Alt-j/k inserts.
nnoremap <silent><C-j> m`:silent +g/m^s*$/d<CR>``:noh<CR>
nnoremap <silent><C-k> m`:silent -g/m^s*$/d<CR>``:noh<CR>
nnoremap <silent><A-j> :set paste<CR>m`o<Esc>``:set nopaste<CR>
nnoremap <silent><A-k> :set paste<CR>m`O<Esc>``:set nopaste<CR>

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

" auto-indent *.py"
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class

" auto-remove trailing white spaces in *.py files"
autocmd BufWritePre *.py normal m`:%s/s+$//e ``

" compatible. You want to use Vim, not vi
set nocp

" Put all swap files in ~/.vim/backup/
"set directory=/tmp/
set directory=~/.vim-swap/

" Remove autocommands just in case
autocmd!

" Filetype support
filetype on
filetype plugin on
filetype indent on

" We put syntax highlighting (COLORS!!)
syntax enable
set bg=dark

nnoremap <silent> <C-l> :nohls<CR><C-l>

" Show the command I am typing
set showcmd

" Show line numbers
set number

" Incremental search, higlighting of search results,
" ignore case.
set is
set hls
set ic
set smartcase

" Show matching ()'s 's {}'s
set sm
" let loaded_matchparen = 1

" Enable folding
set foldmethod=indent
set foldlevel=99

" Enable folding with the spacebar
nnoremap <space> za

" Tabs are 4 spaces long
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smartindent
set cinoptions+=(0
set et
set smartindent
set cindent

" Long lines wrap at white spaces
set linebreak
set wrap
set textwidth=0

" Don't show the intro text
set shortmess+=I

" No need to save to make a :next :previous, etc.
set hidden

" Backspace over anything
set backspace=indent,eol,start

" No bell sound
set noerrorbells

" Smoother changes
set ttyfast

" cabbr js !js ~/.jslint/runjslint.js "`cat %`" | ~/.jslint/format.py


" 20 items in history is for fags "
set history=500

" Remap ` to ' "
nnoremap ' `
nnoremap ` '

" Enable extended % matching "
runtime ~/.vim/plugin/matchit.vim

" By default, pressing <TAB> in command mode will choose the first possible completion with no "
" indication of how many others there might be. "

set wildmenu
"Ignore these files when completing names and in Explorer
set wildignore=.svn,CVS,.git,*.swp,*.jpg,*.png,*.xpm,*.gif,*.bmp,*.pdf,*.db

" Make completion behave similarly to a shell "
set wildmode=list:longest

" make /-style searches case-sensitive only if there is a capital letter in the search expression. "
" *-style searches continue to be consistently case-sensitive. "
set ignorecase
set smartcase

" Set terminal title when vim is run within an xterm "
set title

" Make the scrolling three lines before the border, keeping more context around where you’re working. "
set scrolloff=3

set listchars=tab:>-,trail:·,eol:$
nmap <silent> <leader>s :set nolist!<CR>

" See :help shortmess for the breakdown of what this changes. "
set shortmess=atI

" current directory is always matching the
" content of the active window
set autochdir

" remember some stuff after quiting vim:
" marks, registers, searches, buffer list
set viminfo='20,<50,s10,h,%

" use console dialogs instead of popup
" dialogs for simple choices
set guioptions+=c

" Always show cursor position "
set ruler

if has("autocmd")
" When editing a file, always jump to the last cursor position "
autocmd BufReadPost *
if line("'"") > 0 && line ("'"") <= line("$") |
exe "normal g'"" |
endif
endif

" Usually annoys me "
set nowrap

" Make the completion menus readable "
highlight Pmenu ctermfg=0 ctermbg=3
highlight PmenuSel ctermfg=0 ctermbg=7

"if v:version >= 700
" set cursorline "highlight current line
" set cursorcolumn "highlight current column
"endif

if &diff
"I'm only interested in diff colours
syntax off
endif

"syntax highlight shell scripts as per POSIX,
"not the original Bourne shell which very few use
let g:is_posix = 1

",n to turn off search highlighting
nmap <silent> <leader>n :silent :nohlsearch<CR>

"allow deleting selection without updating the clipboard (yank buffer)
"vnoremap x "_x
"vnoremap X "_X


" Don't move the cursor after pasting
" (by jumping to back start of previously changed text)
noremap p p`[
noremap P P`[

" <home> toggles between start of line and start of text "
imap <khome> <home>
nmap <khome> <home>
inoremap <silent> <home> <C-O>:call Home()<CR>
nnoremap <silent> <home> :call Home()<CR>
function! Home()
let curcol = wincol()
normal ^
let newcol = wincol()
if newcol == curcol
normal 0
endif
endfunction

" <end> goes to end of screen before end of line "
imap <kend> <end>
nmap <kend> <end>
inoremap <silent> <end> <C-O>:call End()<CR>
nnoremap <silent> <end> :call End()<CR>
function! End()
let curcol = wincol()
normal g$
let newcol = wincol()
if newcol == curcol
normal $
endif
"The following is to work around issue for insert mode only.
"normal g$ doesn't go to pos after last char when appropriate.
"More details and patch here:
"http://www.pixelbeat.org/patches/vim-7.0023-eol.diff
if virtcol(".") == virtcol("$") - 1
normal $
endif
endfunction

augroup sh
au!
"smart indent really only for C like languages
au FileType sh set nosmartindent autoindent
augroup END

augroup Python
"See $VIMRUNTIME/ftplugin/python.vim
au!
"smart indent really only for C like languages
"See $VIMRUNTIME/indent/python.vim
au FileType python set nosmartindent autoindent
" Allow gf command to open files in $PYTHONPATH
au FileType python let &path = &path . "," . substitute($PYTHONPATH, ';', ',', 'g')
if v:version >= 700
"See $VIMRUNTIME/autoload/pythoncomplete.vim
"<C-x><C-o> to autocomplete
au FileType python set omnifunc=pythoncomplete#Complete
"Don't show docs in preview window
au FileType python set completeopt-=preview
endif
augroup END

augroup man
au!
"Ensure vim is not recursively invoked (man-db does this)
"when doing ctrl-[ on a man page reference
au FileType man let $MANPAGER=""
augroup END

" i prefer this to visualbell
set noerrorbells

" Hide the mouse pointer while typing
set mousehide

" command NERDTree nt
" let NERDTreeIgnore = ['.pyc$']

" if has("gui_running")
" set clipboard=unnamed
" endif

" let g:nerdtree_tabs_open_on_gui_startup = 0

" Let's keep pseudo tempfiles out of our configs "
let g:netrw_home=substitute($MYVIMRC, 'rc', 'netrw', 'g')


" Powerline "
set nocompatible " Disable vi-compatibility
set laststatus=2 " Always show the statusline
set encoding=utf-8 " Necessary to show Unicode glyphs

let g:pymode_rope_autocomplete_map = '<C-L>'

" Fuck, all HTML is Django"
au BufRead,BufNewFile *.html set filetype=htmldjango
au BufRead,BufNewFile *.sls set filetype=sls

call plug#begin()
Plug 'valloric/ycmd'
Plug 'valloric/youcompleteme'
Plug 'mileszs/ack.vim'
Plug 'airblade/vim-gitgutter'
Plug 'scrooloose/nerdcommenter'
Plug 'majutsushi/tagbar'
Plug 'simeji/winresizer'
Plug 'bling/vim-airline'
Plug 'micha/vim-colors-solarized'
Plug 'scrooloose/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tpope/vim-fugitive'
Plug 'sjl/gundo.vim'
Plug 'groenewege/vim-less'
Plug 'tmhedberg/SimpylFold'
Plug 'vim-scripts/indentpython.vim'
Plug 'klen/python-mode'
Plug 'tpope/vim-surround'
Plug 'scrooloose/syntastic'
Plug 'statianzo/vim-jade'
Plug 'bitc/vim-bad-whitespace'
Plug 'gregsexton/MatchTag'
call plug#end()

" python-mode "

let g:pymode_lint_write = 0

" Gundo "
nnoremap <F5> :GundoToggle<CR>
let g:gundo_width = 60
let g:gundo_preview_height = 40
let g:gundo_right = 1

" SimpylFold "
let g:SimpylFold_docstring_preview=1

" Syntax highlighting if appropriate "
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
set incsearch "For fast terminals can highlight search string as you type
let python_highlight_all=1
syntax on
endif

" MatchTagAlway "
nnoremap <leader>% :MtaJumpToOtherTag<cr>









share|improve this question
























  • I think the extension for vim swapfiles is swp.
    – schaiba
    Feb 16 '17 at 15:39










  • @schaiba Are you able to tell me what is the problem? Do you think each file of that project miss the file.swp file or ...?
    – J.Doe
    Feb 16 '17 at 15:42










  • Have you specified an alternate location for storing Vim's swap files in your .vimrc? If so, does it exist and do you have write permissions there? The swap file is automatically created and serves to help you rescue unsaved edits in case the editor dies. It is not a file you create or view or interact with yourself.
    – Kusalananda
    Feb 16 '17 at 15:44












  • Consider asking your question here: vi.stackexchange.com
    – user13757
    Feb 16 '17 at 15:46










  • @Kusalananda I will put the .vimrc file in my question. Could you tell me what is the problem?
    – J.Doe
    Feb 16 '17 at 15:49















up vote
7
down vote

favorite












In a project, I encounter many errors like this:



E303: Unable to open swap file for "file", recovery impossible


If I execute ls -la |grep vim, I see



-rw-r--r--   1 jeremie jeremie     0 Jan 12 23:58 .ideavimrc
drwxrwxr-x 5 jeremie jeremie 4096 Feb 14 10:00 .vim
-rw------- 1 jeremie jeremie 18887 Feb 16 10:25 .viminfo
-rw-r--r-- 1 jeremie jeremie 9084 Feb 16 10:19 .vimrc
-rw-r--r-- 1 jeremie jeremie 20480 Jan 18 15:17 .vimrc.swn
-rw-r--r-- 1 jeremie jeremie 16384 Jan 15 17:12 .vimrc.swo


Is there a missing file? If so, how would I add this file?



My .vimrc file:



"ycmd debug for YouCompleteMe
let g:ycm_keep_logfiles = 0
let g:ycm_server_python_interpreter = ''

"Auto-Save
let g:auto_save = 1

"Seach words in Vim
set mouse=a

"gitgutter
let g:gitgutter_max_signs = 500 " default value
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk

"Keybinding Tagbar
nnoremap <F8> :TagbarToggle<CR>

"Automatically displays all buffers when there's only one tab open
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'

"Populate the g:airline-symbols dictionary with the powerline symbols
let g:airline_powerline_fonts = 1

" Auto-reload the configuration
augroup myvimrchooks
au!
autocmd bufwritepost .vimrc source ~/.vimrc
augroup END

:set modifiable

nnoremap <F4> :NERDTreeToggle<CR>

set directory=~/.vim/tmp

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif


" Ctrl-j/k deletes blank line below/above, and Alt-j/k inserts.
nnoremap <silent><C-j> m`:silent +g/m^s*$/d<CR>``:noh<CR>
nnoremap <silent><C-k> m`:silent -g/m^s*$/d<CR>``:noh<CR>
nnoremap <silent><A-j> :set paste<CR>m`o<Esc>``:set nopaste<CR>
nnoremap <silent><A-k> :set paste<CR>m`O<Esc>``:set nopaste<CR>

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

" auto-indent *.py"
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class

" auto-remove trailing white spaces in *.py files"
autocmd BufWritePre *.py normal m`:%s/s+$//e ``

" compatible. You want to use Vim, not vi
set nocp

" Put all swap files in ~/.vim/backup/
"set directory=/tmp/
set directory=~/.vim-swap/

" Remove autocommands just in case
autocmd!

" Filetype support
filetype on
filetype plugin on
filetype indent on

" We put syntax highlighting (COLORS!!)
syntax enable
set bg=dark

nnoremap <silent> <C-l> :nohls<CR><C-l>

" Show the command I am typing
set showcmd

" Show line numbers
set number

" Incremental search, higlighting of search results,
" ignore case.
set is
set hls
set ic
set smartcase

" Show matching ()'s 's {}'s
set sm
" let loaded_matchparen = 1

" Enable folding
set foldmethod=indent
set foldlevel=99

" Enable folding with the spacebar
nnoremap <space> za

" Tabs are 4 spaces long
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smartindent
set cinoptions+=(0
set et
set smartindent
set cindent

" Long lines wrap at white spaces
set linebreak
set wrap
set textwidth=0

" Don't show the intro text
set shortmess+=I

" No need to save to make a :next :previous, etc.
set hidden

" Backspace over anything
set backspace=indent,eol,start

" No bell sound
set noerrorbells

" Smoother changes
set ttyfast

" cabbr js !js ~/.jslint/runjslint.js "`cat %`" | ~/.jslint/format.py


" 20 items in history is for fags "
set history=500

" Remap ` to ' "
nnoremap ' `
nnoremap ` '

" Enable extended % matching "
runtime ~/.vim/plugin/matchit.vim

" By default, pressing <TAB> in command mode will choose the first possible completion with no "
" indication of how many others there might be. "

set wildmenu
"Ignore these files when completing names and in Explorer
set wildignore=.svn,CVS,.git,*.swp,*.jpg,*.png,*.xpm,*.gif,*.bmp,*.pdf,*.db

" Make completion behave similarly to a shell "
set wildmode=list:longest

" make /-style searches case-sensitive only if there is a capital letter in the search expression. "
" *-style searches continue to be consistently case-sensitive. "
set ignorecase
set smartcase

" Set terminal title when vim is run within an xterm "
set title

" Make the scrolling three lines before the border, keeping more context around where you’re working. "
set scrolloff=3

set listchars=tab:>-,trail:·,eol:$
nmap <silent> <leader>s :set nolist!<CR>

" See :help shortmess for the breakdown of what this changes. "
set shortmess=atI

" current directory is always matching the
" content of the active window
set autochdir

" remember some stuff after quiting vim:
" marks, registers, searches, buffer list
set viminfo='20,<50,s10,h,%

" use console dialogs instead of popup
" dialogs for simple choices
set guioptions+=c

" Always show cursor position "
set ruler

if has("autocmd")
" When editing a file, always jump to the last cursor position "
autocmd BufReadPost *
if line("'"") > 0 && line ("'"") <= line("$") |
exe "normal g'"" |
endif
endif

" Usually annoys me "
set nowrap

" Make the completion menus readable "
highlight Pmenu ctermfg=0 ctermbg=3
highlight PmenuSel ctermfg=0 ctermbg=7

"if v:version >= 700
" set cursorline "highlight current line
" set cursorcolumn "highlight current column
"endif

if &diff
"I'm only interested in diff colours
syntax off
endif

"syntax highlight shell scripts as per POSIX,
"not the original Bourne shell which very few use
let g:is_posix = 1

",n to turn off search highlighting
nmap <silent> <leader>n :silent :nohlsearch<CR>

"allow deleting selection without updating the clipboard (yank buffer)
"vnoremap x "_x
"vnoremap X "_X


" Don't move the cursor after pasting
" (by jumping to back start of previously changed text)
noremap p p`[
noremap P P`[

" <home> toggles between start of line and start of text "
imap <khome> <home>
nmap <khome> <home>
inoremap <silent> <home> <C-O>:call Home()<CR>
nnoremap <silent> <home> :call Home()<CR>
function! Home()
let curcol = wincol()
normal ^
let newcol = wincol()
if newcol == curcol
normal 0
endif
endfunction

" <end> goes to end of screen before end of line "
imap <kend> <end>
nmap <kend> <end>
inoremap <silent> <end> <C-O>:call End()<CR>
nnoremap <silent> <end> :call End()<CR>
function! End()
let curcol = wincol()
normal g$
let newcol = wincol()
if newcol == curcol
normal $
endif
"The following is to work around issue for insert mode only.
"normal g$ doesn't go to pos after last char when appropriate.
"More details and patch here:
"http://www.pixelbeat.org/patches/vim-7.0023-eol.diff
if virtcol(".") == virtcol("$") - 1
normal $
endif
endfunction

augroup sh
au!
"smart indent really only for C like languages
au FileType sh set nosmartindent autoindent
augroup END

augroup Python
"See $VIMRUNTIME/ftplugin/python.vim
au!
"smart indent really only for C like languages
"See $VIMRUNTIME/indent/python.vim
au FileType python set nosmartindent autoindent
" Allow gf command to open files in $PYTHONPATH
au FileType python let &path = &path . "," . substitute($PYTHONPATH, ';', ',', 'g')
if v:version >= 700
"See $VIMRUNTIME/autoload/pythoncomplete.vim
"<C-x><C-o> to autocomplete
au FileType python set omnifunc=pythoncomplete#Complete
"Don't show docs in preview window
au FileType python set completeopt-=preview
endif
augroup END

augroup man
au!
"Ensure vim is not recursively invoked (man-db does this)
"when doing ctrl-[ on a man page reference
au FileType man let $MANPAGER=""
augroup END

" i prefer this to visualbell
set noerrorbells

" Hide the mouse pointer while typing
set mousehide

" command NERDTree nt
" let NERDTreeIgnore = ['.pyc$']

" if has("gui_running")
" set clipboard=unnamed
" endif

" let g:nerdtree_tabs_open_on_gui_startup = 0

" Let's keep pseudo tempfiles out of our configs "
let g:netrw_home=substitute($MYVIMRC, 'rc', 'netrw', 'g')


" Powerline "
set nocompatible " Disable vi-compatibility
set laststatus=2 " Always show the statusline
set encoding=utf-8 " Necessary to show Unicode glyphs

let g:pymode_rope_autocomplete_map = '<C-L>'

" Fuck, all HTML is Django"
au BufRead,BufNewFile *.html set filetype=htmldjango
au BufRead,BufNewFile *.sls set filetype=sls

call plug#begin()
Plug 'valloric/ycmd'
Plug 'valloric/youcompleteme'
Plug 'mileszs/ack.vim'
Plug 'airblade/vim-gitgutter'
Plug 'scrooloose/nerdcommenter'
Plug 'majutsushi/tagbar'
Plug 'simeji/winresizer'
Plug 'bling/vim-airline'
Plug 'micha/vim-colors-solarized'
Plug 'scrooloose/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tpope/vim-fugitive'
Plug 'sjl/gundo.vim'
Plug 'groenewege/vim-less'
Plug 'tmhedberg/SimpylFold'
Plug 'vim-scripts/indentpython.vim'
Plug 'klen/python-mode'
Plug 'tpope/vim-surround'
Plug 'scrooloose/syntastic'
Plug 'statianzo/vim-jade'
Plug 'bitc/vim-bad-whitespace'
Plug 'gregsexton/MatchTag'
call plug#end()

" python-mode "

let g:pymode_lint_write = 0

" Gundo "
nnoremap <F5> :GundoToggle<CR>
let g:gundo_width = 60
let g:gundo_preview_height = 40
let g:gundo_right = 1

" SimpylFold "
let g:SimpylFold_docstring_preview=1

" Syntax highlighting if appropriate "
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
set incsearch "For fast terminals can highlight search string as you type
let python_highlight_all=1
syntax on
endif

" MatchTagAlway "
nnoremap <leader>% :MtaJumpToOtherTag<cr>









share|improve this question
























  • I think the extension for vim swapfiles is swp.
    – schaiba
    Feb 16 '17 at 15:39










  • @schaiba Are you able to tell me what is the problem? Do you think each file of that project miss the file.swp file or ...?
    – J.Doe
    Feb 16 '17 at 15:42










  • Have you specified an alternate location for storing Vim's swap files in your .vimrc? If so, does it exist and do you have write permissions there? The swap file is automatically created and serves to help you rescue unsaved edits in case the editor dies. It is not a file you create or view or interact with yourself.
    – Kusalananda
    Feb 16 '17 at 15:44












  • Consider asking your question here: vi.stackexchange.com
    – user13757
    Feb 16 '17 at 15:46










  • @Kusalananda I will put the .vimrc file in my question. Could you tell me what is the problem?
    – J.Doe
    Feb 16 '17 at 15:49













up vote
7
down vote

favorite









up vote
7
down vote

favorite











In a project, I encounter many errors like this:



E303: Unable to open swap file for "file", recovery impossible


If I execute ls -la |grep vim, I see



-rw-r--r--   1 jeremie jeremie     0 Jan 12 23:58 .ideavimrc
drwxrwxr-x 5 jeremie jeremie 4096 Feb 14 10:00 .vim
-rw------- 1 jeremie jeremie 18887 Feb 16 10:25 .viminfo
-rw-r--r-- 1 jeremie jeremie 9084 Feb 16 10:19 .vimrc
-rw-r--r-- 1 jeremie jeremie 20480 Jan 18 15:17 .vimrc.swn
-rw-r--r-- 1 jeremie jeremie 16384 Jan 15 17:12 .vimrc.swo


Is there a missing file? If so, how would I add this file?



My .vimrc file:



"ycmd debug for YouCompleteMe
let g:ycm_keep_logfiles = 0
let g:ycm_server_python_interpreter = ''

"Auto-Save
let g:auto_save = 1

"Seach words in Vim
set mouse=a

"gitgutter
let g:gitgutter_max_signs = 500 " default value
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk

"Keybinding Tagbar
nnoremap <F8> :TagbarToggle<CR>

"Automatically displays all buffers when there's only one tab open
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'

"Populate the g:airline-symbols dictionary with the powerline symbols
let g:airline_powerline_fonts = 1

" Auto-reload the configuration
augroup myvimrchooks
au!
autocmd bufwritepost .vimrc source ~/.vimrc
augroup END

:set modifiable

nnoremap <F4> :NERDTreeToggle<CR>

set directory=~/.vim/tmp

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif


" Ctrl-j/k deletes blank line below/above, and Alt-j/k inserts.
nnoremap <silent><C-j> m`:silent +g/m^s*$/d<CR>``:noh<CR>
nnoremap <silent><C-k> m`:silent -g/m^s*$/d<CR>``:noh<CR>
nnoremap <silent><A-j> :set paste<CR>m`o<Esc>``:set nopaste<CR>
nnoremap <silent><A-k> :set paste<CR>m`O<Esc>``:set nopaste<CR>

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

" auto-indent *.py"
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class

" auto-remove trailing white spaces in *.py files"
autocmd BufWritePre *.py normal m`:%s/s+$//e ``

" compatible. You want to use Vim, not vi
set nocp

" Put all swap files in ~/.vim/backup/
"set directory=/tmp/
set directory=~/.vim-swap/

" Remove autocommands just in case
autocmd!

" Filetype support
filetype on
filetype plugin on
filetype indent on

" We put syntax highlighting (COLORS!!)
syntax enable
set bg=dark

nnoremap <silent> <C-l> :nohls<CR><C-l>

" Show the command I am typing
set showcmd

" Show line numbers
set number

" Incremental search, higlighting of search results,
" ignore case.
set is
set hls
set ic
set smartcase

" Show matching ()'s 's {}'s
set sm
" let loaded_matchparen = 1

" Enable folding
set foldmethod=indent
set foldlevel=99

" Enable folding with the spacebar
nnoremap <space> za

" Tabs are 4 spaces long
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smartindent
set cinoptions+=(0
set et
set smartindent
set cindent

" Long lines wrap at white spaces
set linebreak
set wrap
set textwidth=0

" Don't show the intro text
set shortmess+=I

" No need to save to make a :next :previous, etc.
set hidden

" Backspace over anything
set backspace=indent,eol,start

" No bell sound
set noerrorbells

" Smoother changes
set ttyfast

" cabbr js !js ~/.jslint/runjslint.js "`cat %`" | ~/.jslint/format.py


" 20 items in history is for fags "
set history=500

" Remap ` to ' "
nnoremap ' `
nnoremap ` '

" Enable extended % matching "
runtime ~/.vim/plugin/matchit.vim

" By default, pressing <TAB> in command mode will choose the first possible completion with no "
" indication of how many others there might be. "

set wildmenu
"Ignore these files when completing names and in Explorer
set wildignore=.svn,CVS,.git,*.swp,*.jpg,*.png,*.xpm,*.gif,*.bmp,*.pdf,*.db

" Make completion behave similarly to a shell "
set wildmode=list:longest

" make /-style searches case-sensitive only if there is a capital letter in the search expression. "
" *-style searches continue to be consistently case-sensitive. "
set ignorecase
set smartcase

" Set terminal title when vim is run within an xterm "
set title

" Make the scrolling three lines before the border, keeping more context around where you’re working. "
set scrolloff=3

set listchars=tab:>-,trail:·,eol:$
nmap <silent> <leader>s :set nolist!<CR>

" See :help shortmess for the breakdown of what this changes. "
set shortmess=atI

" current directory is always matching the
" content of the active window
set autochdir

" remember some stuff after quiting vim:
" marks, registers, searches, buffer list
set viminfo='20,<50,s10,h,%

" use console dialogs instead of popup
" dialogs for simple choices
set guioptions+=c

" Always show cursor position "
set ruler

if has("autocmd")
" When editing a file, always jump to the last cursor position "
autocmd BufReadPost *
if line("'"") > 0 && line ("'"") <= line("$") |
exe "normal g'"" |
endif
endif

" Usually annoys me "
set nowrap

" Make the completion menus readable "
highlight Pmenu ctermfg=0 ctermbg=3
highlight PmenuSel ctermfg=0 ctermbg=7

"if v:version >= 700
" set cursorline "highlight current line
" set cursorcolumn "highlight current column
"endif

if &diff
"I'm only interested in diff colours
syntax off
endif

"syntax highlight shell scripts as per POSIX,
"not the original Bourne shell which very few use
let g:is_posix = 1

",n to turn off search highlighting
nmap <silent> <leader>n :silent :nohlsearch<CR>

"allow deleting selection without updating the clipboard (yank buffer)
"vnoremap x "_x
"vnoremap X "_X


" Don't move the cursor after pasting
" (by jumping to back start of previously changed text)
noremap p p`[
noremap P P`[

" <home> toggles between start of line and start of text "
imap <khome> <home>
nmap <khome> <home>
inoremap <silent> <home> <C-O>:call Home()<CR>
nnoremap <silent> <home> :call Home()<CR>
function! Home()
let curcol = wincol()
normal ^
let newcol = wincol()
if newcol == curcol
normal 0
endif
endfunction

" <end> goes to end of screen before end of line "
imap <kend> <end>
nmap <kend> <end>
inoremap <silent> <end> <C-O>:call End()<CR>
nnoremap <silent> <end> :call End()<CR>
function! End()
let curcol = wincol()
normal g$
let newcol = wincol()
if newcol == curcol
normal $
endif
"The following is to work around issue for insert mode only.
"normal g$ doesn't go to pos after last char when appropriate.
"More details and patch here:
"http://www.pixelbeat.org/patches/vim-7.0023-eol.diff
if virtcol(".") == virtcol("$") - 1
normal $
endif
endfunction

augroup sh
au!
"smart indent really only for C like languages
au FileType sh set nosmartindent autoindent
augroup END

augroup Python
"See $VIMRUNTIME/ftplugin/python.vim
au!
"smart indent really only for C like languages
"See $VIMRUNTIME/indent/python.vim
au FileType python set nosmartindent autoindent
" Allow gf command to open files in $PYTHONPATH
au FileType python let &path = &path . "," . substitute($PYTHONPATH, ';', ',', 'g')
if v:version >= 700
"See $VIMRUNTIME/autoload/pythoncomplete.vim
"<C-x><C-o> to autocomplete
au FileType python set omnifunc=pythoncomplete#Complete
"Don't show docs in preview window
au FileType python set completeopt-=preview
endif
augroup END

augroup man
au!
"Ensure vim is not recursively invoked (man-db does this)
"when doing ctrl-[ on a man page reference
au FileType man let $MANPAGER=""
augroup END

" i prefer this to visualbell
set noerrorbells

" Hide the mouse pointer while typing
set mousehide

" command NERDTree nt
" let NERDTreeIgnore = ['.pyc$']

" if has("gui_running")
" set clipboard=unnamed
" endif

" let g:nerdtree_tabs_open_on_gui_startup = 0

" Let's keep pseudo tempfiles out of our configs "
let g:netrw_home=substitute($MYVIMRC, 'rc', 'netrw', 'g')


" Powerline "
set nocompatible " Disable vi-compatibility
set laststatus=2 " Always show the statusline
set encoding=utf-8 " Necessary to show Unicode glyphs

let g:pymode_rope_autocomplete_map = '<C-L>'

" Fuck, all HTML is Django"
au BufRead,BufNewFile *.html set filetype=htmldjango
au BufRead,BufNewFile *.sls set filetype=sls

call plug#begin()
Plug 'valloric/ycmd'
Plug 'valloric/youcompleteme'
Plug 'mileszs/ack.vim'
Plug 'airblade/vim-gitgutter'
Plug 'scrooloose/nerdcommenter'
Plug 'majutsushi/tagbar'
Plug 'simeji/winresizer'
Plug 'bling/vim-airline'
Plug 'micha/vim-colors-solarized'
Plug 'scrooloose/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tpope/vim-fugitive'
Plug 'sjl/gundo.vim'
Plug 'groenewege/vim-less'
Plug 'tmhedberg/SimpylFold'
Plug 'vim-scripts/indentpython.vim'
Plug 'klen/python-mode'
Plug 'tpope/vim-surround'
Plug 'scrooloose/syntastic'
Plug 'statianzo/vim-jade'
Plug 'bitc/vim-bad-whitespace'
Plug 'gregsexton/MatchTag'
call plug#end()

" python-mode "

let g:pymode_lint_write = 0

" Gundo "
nnoremap <F5> :GundoToggle<CR>
let g:gundo_width = 60
let g:gundo_preview_height = 40
let g:gundo_right = 1

" SimpylFold "
let g:SimpylFold_docstring_preview=1

" Syntax highlighting if appropriate "
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
set incsearch "For fast terminals can highlight search string as you type
let python_highlight_all=1
syntax on
endif

" MatchTagAlway "
nnoremap <leader>% :MtaJumpToOtherTag<cr>









share|improve this question















In a project, I encounter many errors like this:



E303: Unable to open swap file for "file", recovery impossible


If I execute ls -la |grep vim, I see



-rw-r--r--   1 jeremie jeremie     0 Jan 12 23:58 .ideavimrc
drwxrwxr-x 5 jeremie jeremie 4096 Feb 14 10:00 .vim
-rw------- 1 jeremie jeremie 18887 Feb 16 10:25 .viminfo
-rw-r--r-- 1 jeremie jeremie 9084 Feb 16 10:19 .vimrc
-rw-r--r-- 1 jeremie jeremie 20480 Jan 18 15:17 .vimrc.swn
-rw-r--r-- 1 jeremie jeremie 16384 Jan 15 17:12 .vimrc.swo


Is there a missing file? If so, how would I add this file?



My .vimrc file:



"ycmd debug for YouCompleteMe
let g:ycm_keep_logfiles = 0
let g:ycm_server_python_interpreter = ''

"Auto-Save
let g:auto_save = 1

"Seach words in Vim
set mouse=a

"gitgutter
let g:gitgutter_max_signs = 500 " default value
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk

"Keybinding Tagbar
nnoremap <F8> :TagbarToggle<CR>

"Automatically displays all buffers when there's only one tab open
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'

"Populate the g:airline-symbols dictionary with the powerline symbols
let g:airline_powerline_fonts = 1

" Auto-reload the configuration
augroup myvimrchooks
au!
autocmd bufwritepost .vimrc source ~/.vimrc
augroup END

:set modifiable

nnoremap <F4> :NERDTreeToggle<CR>

set directory=~/.vim/tmp

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif


" Ctrl-j/k deletes blank line below/above, and Alt-j/k inserts.
nnoremap <silent><C-j> m`:silent +g/m^s*$/d<CR>``:noh<CR>
nnoremap <silent><C-k> m`:silent -g/m^s*$/d<CR>``:noh<CR>
nnoremap <silent><A-j> :set paste<CR>m`o<Esc>``:set nopaste<CR>
nnoremap <silent><A-k> :set paste<CR>m`O<Esc>``:set nopaste<CR>

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

" auto-indent *.py"
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class

" auto-remove trailing white spaces in *.py files"
autocmd BufWritePre *.py normal m`:%s/s+$//e ``

" compatible. You want to use Vim, not vi
set nocp

" Put all swap files in ~/.vim/backup/
"set directory=/tmp/
set directory=~/.vim-swap/

" Remove autocommands just in case
autocmd!

" Filetype support
filetype on
filetype plugin on
filetype indent on

" We put syntax highlighting (COLORS!!)
syntax enable
set bg=dark

nnoremap <silent> <C-l> :nohls<CR><C-l>

" Show the command I am typing
set showcmd

" Show line numbers
set number

" Incremental search, higlighting of search results,
" ignore case.
set is
set hls
set ic
set smartcase

" Show matching ()'s 's {}'s
set sm
" let loaded_matchparen = 1

" Enable folding
set foldmethod=indent
set foldlevel=99

" Enable folding with the spacebar
nnoremap <space> za

" Tabs are 4 spaces long
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smartindent
set cinoptions+=(0
set et
set smartindent
set cindent

" Long lines wrap at white spaces
set linebreak
set wrap
set textwidth=0

" Don't show the intro text
set shortmess+=I

" No need to save to make a :next :previous, etc.
set hidden

" Backspace over anything
set backspace=indent,eol,start

" No bell sound
set noerrorbells

" Smoother changes
set ttyfast

" cabbr js !js ~/.jslint/runjslint.js "`cat %`" | ~/.jslint/format.py


" 20 items in history is for fags "
set history=500

" Remap ` to ' "
nnoremap ' `
nnoremap ` '

" Enable extended % matching "
runtime ~/.vim/plugin/matchit.vim

" By default, pressing <TAB> in command mode will choose the first possible completion with no "
" indication of how many others there might be. "

set wildmenu
"Ignore these files when completing names and in Explorer
set wildignore=.svn,CVS,.git,*.swp,*.jpg,*.png,*.xpm,*.gif,*.bmp,*.pdf,*.db

" Make completion behave similarly to a shell "
set wildmode=list:longest

" make /-style searches case-sensitive only if there is a capital letter in the search expression. "
" *-style searches continue to be consistently case-sensitive. "
set ignorecase
set smartcase

" Set terminal title when vim is run within an xterm "
set title

" Make the scrolling three lines before the border, keeping more context around where you’re working. "
set scrolloff=3

set listchars=tab:>-,trail:·,eol:$
nmap <silent> <leader>s :set nolist!<CR>

" See :help shortmess for the breakdown of what this changes. "
set shortmess=atI

" current directory is always matching the
" content of the active window
set autochdir

" remember some stuff after quiting vim:
" marks, registers, searches, buffer list
set viminfo='20,<50,s10,h,%

" use console dialogs instead of popup
" dialogs for simple choices
set guioptions+=c

" Always show cursor position "
set ruler

if has("autocmd")
" When editing a file, always jump to the last cursor position "
autocmd BufReadPost *
if line("'"") > 0 && line ("'"") <= line("$") |
exe "normal g'"" |
endif
endif

" Usually annoys me "
set nowrap

" Make the completion menus readable "
highlight Pmenu ctermfg=0 ctermbg=3
highlight PmenuSel ctermfg=0 ctermbg=7

"if v:version >= 700
" set cursorline "highlight current line
" set cursorcolumn "highlight current column
"endif

if &diff
"I'm only interested in diff colours
syntax off
endif

"syntax highlight shell scripts as per POSIX,
"not the original Bourne shell which very few use
let g:is_posix = 1

",n to turn off search highlighting
nmap <silent> <leader>n :silent :nohlsearch<CR>

"allow deleting selection without updating the clipboard (yank buffer)
"vnoremap x "_x
"vnoremap X "_X


" Don't move the cursor after pasting
" (by jumping to back start of previously changed text)
noremap p p`[
noremap P P`[

" <home> toggles between start of line and start of text "
imap <khome> <home>
nmap <khome> <home>
inoremap <silent> <home> <C-O>:call Home()<CR>
nnoremap <silent> <home> :call Home()<CR>
function! Home()
let curcol = wincol()
normal ^
let newcol = wincol()
if newcol == curcol
normal 0
endif
endfunction

" <end> goes to end of screen before end of line "
imap <kend> <end>
nmap <kend> <end>
inoremap <silent> <end> <C-O>:call End()<CR>
nnoremap <silent> <end> :call End()<CR>
function! End()
let curcol = wincol()
normal g$
let newcol = wincol()
if newcol == curcol
normal $
endif
"The following is to work around issue for insert mode only.
"normal g$ doesn't go to pos after last char when appropriate.
"More details and patch here:
"http://www.pixelbeat.org/patches/vim-7.0023-eol.diff
if virtcol(".") == virtcol("$") - 1
normal $
endif
endfunction

augroup sh
au!
"smart indent really only for C like languages
au FileType sh set nosmartindent autoindent
augroup END

augroup Python
"See $VIMRUNTIME/ftplugin/python.vim
au!
"smart indent really only for C like languages
"See $VIMRUNTIME/indent/python.vim
au FileType python set nosmartindent autoindent
" Allow gf command to open files in $PYTHONPATH
au FileType python let &path = &path . "," . substitute($PYTHONPATH, ';', ',', 'g')
if v:version >= 700
"See $VIMRUNTIME/autoload/pythoncomplete.vim
"<C-x><C-o> to autocomplete
au FileType python set omnifunc=pythoncomplete#Complete
"Don't show docs in preview window
au FileType python set completeopt-=preview
endif
augroup END

augroup man
au!
"Ensure vim is not recursively invoked (man-db does this)
"when doing ctrl-[ on a man page reference
au FileType man let $MANPAGER=""
augroup END

" i prefer this to visualbell
set noerrorbells

" Hide the mouse pointer while typing
set mousehide

" command NERDTree nt
" let NERDTreeIgnore = ['.pyc$']

" if has("gui_running")
" set clipboard=unnamed
" endif

" let g:nerdtree_tabs_open_on_gui_startup = 0

" Let's keep pseudo tempfiles out of our configs "
let g:netrw_home=substitute($MYVIMRC, 'rc', 'netrw', 'g')


" Powerline "
set nocompatible " Disable vi-compatibility
set laststatus=2 " Always show the statusline
set encoding=utf-8 " Necessary to show Unicode glyphs

let g:pymode_rope_autocomplete_map = '<C-L>'

" Fuck, all HTML is Django"
au BufRead,BufNewFile *.html set filetype=htmldjango
au BufRead,BufNewFile *.sls set filetype=sls

call plug#begin()
Plug 'valloric/ycmd'
Plug 'valloric/youcompleteme'
Plug 'mileszs/ack.vim'
Plug 'airblade/vim-gitgutter'
Plug 'scrooloose/nerdcommenter'
Plug 'majutsushi/tagbar'
Plug 'simeji/winresizer'
Plug 'bling/vim-airline'
Plug 'micha/vim-colors-solarized'
Plug 'scrooloose/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tpope/vim-fugitive'
Plug 'sjl/gundo.vim'
Plug 'groenewege/vim-less'
Plug 'tmhedberg/SimpylFold'
Plug 'vim-scripts/indentpython.vim'
Plug 'klen/python-mode'
Plug 'tpope/vim-surround'
Plug 'scrooloose/syntastic'
Plug 'statianzo/vim-jade'
Plug 'bitc/vim-bad-whitespace'
Plug 'gregsexton/MatchTag'
call plug#end()

" python-mode "

let g:pymode_lint_write = 0

" Gundo "
nnoremap <F5> :GundoToggle<CR>
let g:gundo_width = 60
let g:gundo_preview_height = 40
let g:gundo_right = 1

" SimpylFold "
let g:SimpylFold_docstring_preview=1

" Syntax highlighting if appropriate "
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
set incsearch "For fast terminals can highlight search string as you type
let python_highlight_all=1
syntax on
endif

" MatchTagAlway "
nnoremap <leader>% :MtaJumpToOtherTag<cr>






vim






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 13 at 17:32









Matthias Braun

1,78721120




1,78721120










asked Feb 16 '17 at 15:33









J.Doe

6917




6917












  • I think the extension for vim swapfiles is swp.
    – schaiba
    Feb 16 '17 at 15:39










  • @schaiba Are you able to tell me what is the problem? Do you think each file of that project miss the file.swp file or ...?
    – J.Doe
    Feb 16 '17 at 15:42










  • Have you specified an alternate location for storing Vim's swap files in your .vimrc? If so, does it exist and do you have write permissions there? The swap file is automatically created and serves to help you rescue unsaved edits in case the editor dies. It is not a file you create or view or interact with yourself.
    – Kusalananda
    Feb 16 '17 at 15:44












  • Consider asking your question here: vi.stackexchange.com
    – user13757
    Feb 16 '17 at 15:46










  • @Kusalananda I will put the .vimrc file in my question. Could you tell me what is the problem?
    – J.Doe
    Feb 16 '17 at 15:49


















  • I think the extension for vim swapfiles is swp.
    – schaiba
    Feb 16 '17 at 15:39










  • @schaiba Are you able to tell me what is the problem? Do you think each file of that project miss the file.swp file or ...?
    – J.Doe
    Feb 16 '17 at 15:42










  • Have you specified an alternate location for storing Vim's swap files in your .vimrc? If so, does it exist and do you have write permissions there? The swap file is automatically created and serves to help you rescue unsaved edits in case the editor dies. It is not a file you create or view or interact with yourself.
    – Kusalananda
    Feb 16 '17 at 15:44












  • Consider asking your question here: vi.stackexchange.com
    – user13757
    Feb 16 '17 at 15:46










  • @Kusalananda I will put the .vimrc file in my question. Could you tell me what is the problem?
    – J.Doe
    Feb 16 '17 at 15:49
















I think the extension for vim swapfiles is swp.
– schaiba
Feb 16 '17 at 15:39




I think the extension for vim swapfiles is swp.
– schaiba
Feb 16 '17 at 15:39












@schaiba Are you able to tell me what is the problem? Do you think each file of that project miss the file.swp file or ...?
– J.Doe
Feb 16 '17 at 15:42




@schaiba Are you able to tell me what is the problem? Do you think each file of that project miss the file.swp file or ...?
– J.Doe
Feb 16 '17 at 15:42












Have you specified an alternate location for storing Vim's swap files in your .vimrc? If so, does it exist and do you have write permissions there? The swap file is automatically created and serves to help you rescue unsaved edits in case the editor dies. It is not a file you create or view or interact with yourself.
– Kusalananda
Feb 16 '17 at 15:44






Have you specified an alternate location for storing Vim's swap files in your .vimrc? If so, does it exist and do you have write permissions there? The swap file is automatically created and serves to help you rescue unsaved edits in case the editor dies. It is not a file you create or view or interact with yourself.
– Kusalananda
Feb 16 '17 at 15:44














Consider asking your question here: vi.stackexchange.com
– user13757
Feb 16 '17 at 15:46




Consider asking your question here: vi.stackexchange.com
– user13757
Feb 16 '17 at 15:46












@Kusalananda I will put the .vimrc file in my question. Could you tell me what is the problem?
– J.Doe
Feb 16 '17 at 15:49




@Kusalananda I will put the .vimrc file in my question. Could you tell me what is the problem?
– J.Doe
Feb 16 '17 at 15:49










2 Answers
2






active

oldest

votes

















up vote
10
down vote













In your ~/.vimrc file you have



set directory=~/.vim/tmp


and then further down, again,



set directory=~/.vim-swap/


This means that vim will use that (second) directory for storing its swap files.



If ~/.vim-swap does not exist or if it's not a writable directory, you will get the error that you mention.



Most of the time, there is no reason to use this setting at all.



From the vim manual, about this error (viewable in vim by :help E303):




Vim was not able to create a swap file. You can still edit the file, but if
Vim unexpectedly exits the changes will be lost. And Vim may consume a lot of
memory when editing a big file. You may want to change the 'directory' option
to avoid this error. See swap-file.







share|improve this answer























  • In my case I also had to give the necessary permissions for accessing tmp folder. Using sudo chown your_username:your_username /home/your_username/.vim/tmp
    – markroxor
    Aug 2 at 13:39




















up vote
0
down vote













Add this at the beginning of your vimrc file:



if empty(glob('~/.vim/tmp'))
silent !mkdir -p ~/.vim/tmp
endif
set directory=$HOME/.vim/tmp


It will check and create if necessary tmp folder






share|improve this answer








New contributor




mef_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • If they added this to their already quite huge .vimrc file, at the start, the directory setting would be overwritten by set directory=~/.vim-swap/ later in the file.
    – Kusalananda
    Nov 15 at 10:00











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f345494%2fvim-swap-file-issue%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
10
down vote













In your ~/.vimrc file you have



set directory=~/.vim/tmp


and then further down, again,



set directory=~/.vim-swap/


This means that vim will use that (second) directory for storing its swap files.



If ~/.vim-swap does not exist or if it's not a writable directory, you will get the error that you mention.



Most of the time, there is no reason to use this setting at all.



From the vim manual, about this error (viewable in vim by :help E303):




Vim was not able to create a swap file. You can still edit the file, but if
Vim unexpectedly exits the changes will be lost. And Vim may consume a lot of
memory when editing a big file. You may want to change the 'directory' option
to avoid this error. See swap-file.







share|improve this answer























  • In my case I also had to give the necessary permissions for accessing tmp folder. Using sudo chown your_username:your_username /home/your_username/.vim/tmp
    – markroxor
    Aug 2 at 13:39

















up vote
10
down vote













In your ~/.vimrc file you have



set directory=~/.vim/tmp


and then further down, again,



set directory=~/.vim-swap/


This means that vim will use that (second) directory for storing its swap files.



If ~/.vim-swap does not exist or if it's not a writable directory, you will get the error that you mention.



Most of the time, there is no reason to use this setting at all.



From the vim manual, about this error (viewable in vim by :help E303):




Vim was not able to create a swap file. You can still edit the file, but if
Vim unexpectedly exits the changes will be lost. And Vim may consume a lot of
memory when editing a big file. You may want to change the 'directory' option
to avoid this error. See swap-file.







share|improve this answer























  • In my case I also had to give the necessary permissions for accessing tmp folder. Using sudo chown your_username:your_username /home/your_username/.vim/tmp
    – markroxor
    Aug 2 at 13:39















up vote
10
down vote










up vote
10
down vote









In your ~/.vimrc file you have



set directory=~/.vim/tmp


and then further down, again,



set directory=~/.vim-swap/


This means that vim will use that (second) directory for storing its swap files.



If ~/.vim-swap does not exist or if it's not a writable directory, you will get the error that you mention.



Most of the time, there is no reason to use this setting at all.



From the vim manual, about this error (viewable in vim by :help E303):




Vim was not able to create a swap file. You can still edit the file, but if
Vim unexpectedly exits the changes will be lost. And Vim may consume a lot of
memory when editing a big file. You may want to change the 'directory' option
to avoid this error. See swap-file.







share|improve this answer














In your ~/.vimrc file you have



set directory=~/.vim/tmp


and then further down, again,



set directory=~/.vim-swap/


This means that vim will use that (second) directory for storing its swap files.



If ~/.vim-swap does not exist or if it's not a writable directory, you will get the error that you mention.



Most of the time, there is no reason to use this setting at all.



From the vim manual, about this error (viewable in vim by :help E303):




Vim was not able to create a swap file. You can still edit the file, but if
Vim unexpectedly exits the changes will be lost. And Vim may consume a lot of
memory when editing a big file. You may want to change the 'directory' option
to avoid this error. See swap-file.








share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 5 at 19:03

























answered Feb 16 '17 at 15:54









Kusalananda

116k15218351




116k15218351












  • In my case I also had to give the necessary permissions for accessing tmp folder. Using sudo chown your_username:your_username /home/your_username/.vim/tmp
    – markroxor
    Aug 2 at 13:39




















  • In my case I also had to give the necessary permissions for accessing tmp folder. Using sudo chown your_username:your_username /home/your_username/.vim/tmp
    – markroxor
    Aug 2 at 13:39


















In my case I also had to give the necessary permissions for accessing tmp folder. Using sudo chown your_username:your_username /home/your_username/.vim/tmp
– markroxor
Aug 2 at 13:39






In my case I also had to give the necessary permissions for accessing tmp folder. Using sudo chown your_username:your_username /home/your_username/.vim/tmp
– markroxor
Aug 2 at 13:39














up vote
0
down vote













Add this at the beginning of your vimrc file:



if empty(glob('~/.vim/tmp'))
silent !mkdir -p ~/.vim/tmp
endif
set directory=$HOME/.vim/tmp


It will check and create if necessary tmp folder






share|improve this answer








New contributor




mef_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • If they added this to their already quite huge .vimrc file, at the start, the directory setting would be overwritten by set directory=~/.vim-swap/ later in the file.
    – Kusalananda
    Nov 15 at 10:00















up vote
0
down vote













Add this at the beginning of your vimrc file:



if empty(glob('~/.vim/tmp'))
silent !mkdir -p ~/.vim/tmp
endif
set directory=$HOME/.vim/tmp


It will check and create if necessary tmp folder






share|improve this answer








New contributor




mef_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • If they added this to their already quite huge .vimrc file, at the start, the directory setting would be overwritten by set directory=~/.vim-swap/ later in the file.
    – Kusalananda
    Nov 15 at 10:00













up vote
0
down vote










up vote
0
down vote









Add this at the beginning of your vimrc file:



if empty(glob('~/.vim/tmp'))
silent !mkdir -p ~/.vim/tmp
endif
set directory=$HOME/.vim/tmp


It will check and create if necessary tmp folder






share|improve this answer








New contributor




mef_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









Add this at the beginning of your vimrc file:



if empty(glob('~/.vim/tmp'))
silent !mkdir -p ~/.vim/tmp
endif
set directory=$HOME/.vim/tmp


It will check and create if necessary tmp folder







share|improve this answer








New contributor




mef_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




mef_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered Nov 15 at 9:08









mef_

1




1




New contributor




mef_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





mef_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






mef_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • If they added this to their already quite huge .vimrc file, at the start, the directory setting would be overwritten by set directory=~/.vim-swap/ later in the file.
    – Kusalananda
    Nov 15 at 10:00


















  • If they added this to their already quite huge .vimrc file, at the start, the directory setting would be overwritten by set directory=~/.vim-swap/ later in the file.
    – Kusalananda
    Nov 15 at 10:00
















If they added this to their already quite huge .vimrc file, at the start, the directory setting would be overwritten by set directory=~/.vim-swap/ later in the file.
– Kusalananda
Nov 15 at 10:00




If they added this to their already quite huge .vimrc file, at the start, the directory setting would be overwritten by set directory=~/.vim-swap/ later in the file.
– Kusalananda
Nov 15 at 10:00


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f345494%2fvim-swap-file-issue%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Morgemoulin

Scott Moir

Souastre